fachinformatiker-wiki

it's easy when it's here

User Tools

Site Tools


linux:bash_script

Bash-Scripts

!#/bin/bash

Bash-Script:

#!/bin/bash
 
echo "Lieber $1,"
echo
echo "lange nichts von Dir gehört."
echo "Geht es dir gut?"
echo "Melde Dich mal wieder!"
echo
echo "Liebe Grüße"
echo
echo "$2"

Befehl:

./script Hans Peter

Ausgabe:

Lieber Hans,

lange nichts von Dir gehört.
Geht es dir gut?
Melde Dich mal wieder!

Liebe Grüße

Peter

Quellcode

while [ $1 ]; do
	echo Hallo Ich bin die Datei $1 > datei$1.txt
	shift
done

Script:

#!/bin/bash
 
ausgabe=''
 
for i in $@
do
 
        ausgabe="$i $ausgabe"
done
echo $ausgabe

Ausgabe:

schueler@ubuntu:~$ ./backwards 1 2 3 4 5 6 7 8 9 0
0 9 8 7 6 5 4 3 2 1
#!/bin/bash
DBUSER="root"
USERPW="password"
DBHOST="localhost"
anzTage="180"
LOGFILE="/mysql.log"
 
/usr/bin/mysql -h ${DBHOST} --user=${DBUSER} --password=${USERPW} -e "DELETE FROM user WHERE DATEDIFF(CURDATE(), datum) <= '${anzTage}';" && /bin/echo "`/bin/date +'%Y-%m-%d %H:%M:%S'`: Eintraege der letzten ${anzTage} Tage wurden geloescht" >> ${LOGFILE} || /bin/echo "`/bin/date +'%Y-%m-%d %H:%M:%S'`: Loeschen fehlgeschlagen." >> ${LOGFILE}
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.  More information about cookies 
linux/bash_script.txt · Last modified: 2024/02/17 19:03 by 127.0.0.1