Skip to content
Snippets Groups Projects
Commit a8c15674 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispiele 23.4.2021

parent fa6aae00
Branches
No related tags found
No related merge requests found
Showing
with 180 additions and 0 deletions
cassini/home/peter/bo/2021ss/bs/20210423> file_template=$(ls -rt *.c *.cpp *.sh *.py *.tex *.diff 2>/dev/null | tail -1)
cassini/home/peter/bo/2021ss/bs/20210423> echo $file_template
params-3.sh
cassini/home/peter/bo/2021ss/bs/20210423>
#include <stdio.h>
int main (void)
{
printf ("Bonjour le monde !\n");
return 1;
}
cassini/home/peter/bo/2021ss/bs/20210423> gcc -Wall -O test-5.c -o test-5
cassini/home/peter/bo/2021ss/bs/20210423> ./test-5
Bonjour le monde !
cassini/home/peter/bo/2021ss/bs/20210423> if ./test-5; then echo "Merci."; else echo "C'est dommage."; fi
Bonjour le monde !
C'est dommage.
cassini/home/peter/bo/2021ss/bs/20210423> if ./test-4; then echo "Merci."; else echo "C'est dommage."; fi
Bonjour le monde !
Merci.
cassini/home/peter/bo/2021ss/bs/20210423>
#include <stdio.h>
int main (void)
{
printf ("Bonjour le monde !\n")
return 1
}
cassini/home/peter/bo/2021ss/bs/20210423> gcc -Wall -O test-6.c -o test-6 && ./test-6
test-6.c: In function ‘main’:
test-6.c:5:34: error: expected ‘;’ before ‘return’
printf ("Bonjour le monde !\n")
^
;
return 1
~~~~~~
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> echo $USER
peter
cassini/home/peter/bo/2021ss/bs/20210423> if [ "$USER" = "peter" ]; then echo "Hallo, Peter!"; else echo "Hallo, wer auch immer!"; fi
Hallo, Peter!
cassini/home/peter/bo/2021ss/bs/20210423> echo $DISPLAY
:5
cassini/home/peter/bo/2021ss/bs/20210423> if [ -n "$DISPLAY" ]; then xeyes; else echo "Keine Grafik!"; fi
Beendet
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> del *wichtig*
unwichtig-1.txt unwichtig-3.txt unwichtig-5.txt unwichtig-7.txt
unwichtig-2.txt unwichtig-4.txt unwichtig-6.txt
Press ENTER to delete, ^C to abort.
cassini/home/peter/bo/2021ss/bs/20210423> which del
/home/peter/usr/bin/del
cassini/home/peter/bo/2021ss/bs/20210423> cat $(which del)
#!/bin/sh
ls "$@"
echo -n "Press ENTER to delete, ^C to abort."
read junk
rm "$@"
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> read name
Peter
cassini/home/peter/bo/2021ss/bs/20210423> echo "Hallo, $name!"
Hallo, Peter!
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> echo "Dies ist ein Test." > test.txt
cassini/home/peter/bo/2021ss/bs/20210423> cat test.txt
Dies ist ein Test.
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> echo "Dies auch." >> test.txt
cassini/home/peter/bo/2021ss/bs/20210423> cat test.txt
Dies ist ein Test.
Dies auch.
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> grep -l Hello *
grep-1.txt
grep-2.txt
grep-3.txt
grep: test: Ist ein Verzeichnis
test-1.c
test-2.c
unix-20210423.tex
cassini/home/peter/bo/2021ss/bs/20210423> grep -l Hello * > hello-files.txt
grep: test: Ist ein Verzeichnis
cassini/home/peter/bo/2021ss/bs/20210423> cat hello-files.txt
grep-1.txt
grep-2.txt
grep-3.txt
test-1.c
test-2.c
unix-20210423.tex
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> grep -l Hello *
grep-1.txt
grep-2.txt
grep-3.txt
iostreams-3.txt
grep: test: Ist ein Verzeichnis
test-1.c
test-2.c
unix-20210423.tex
cassini/home/peter/bo/2021ss/bs/20210423> grep -l Hello * 2> hello-error.txt
grep-1.txt
grep-2.txt
grep-3.txt
iostreams-3.txt
test-1.c
test-2.c
unix-20210423.tex
cassini/home/peter/bo/2021ss/bs/20210423> cat hello-error.txt
grep: test: Ist ein Verzeichnis
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> grep -l Hello * > hello-files-and-error.txt 2>&1
cassini/home/peter/bo/2021ss/bs/20210423> cat hello-files-and-error.txt
grep-1.txt
grep-2.txt
grep-3.txt
iostreams-3.txt
iostreams-4.txt
grep: test: Ist ein Verzeichnis
test-1.c
test-2.c
unix-20210423.tex
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> echo 'Fehler!!!' 1>&2
Fehler!!!
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> echo "2 + 2" > "test.bc"
cassini/home/peter/bo/2021ss/bs/20210423> bc < test.bc
4
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> echo "2 + 2" | bc
4
cassini/home/peter/bo/2021ss/bs/20210423>
cassini/home/peter/bo/2021ss/bs/20210423> ls -rt *.c *.cpp *.sh *.py *.tex *.diff ls: Zugriff auf '*.cpp' nicht möglich: Datei oder Verzeichnis nicht gefunden
ls: Zugriff auf '*.py' nicht möglich: Datei oder Verzeichnis nicht gefunden
ls: Zugriff auf '*.diff' nicht möglich: Datei oder Verzeichnis nicht gefunden
unix-20210423.tex test-1.c test-4.c params-2.sh
test-2.c test-3.c params-1.sh params-3.sh
cassini/home/peter/bo/2021ss/bs/20210423> ls -rt *.c *.cpp *.sh *.py *.tex *.diff 2>/dev/null unix-20210423.tex test-1.c test-4.c params-2.sh
test-2.c test-3.c params-1.sh params-3.sh
cassini/home/peter/bo/2021ss/bs/20210423> ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Apr 6 09:59 /dev/null
cassini/home/peter/bo/2021ss/bs/20210423>
#!/bin/bash
echo $1
#!/bin/bash
echo $1
cassini/home/peter/bo/2021ss/bs/20210423> chmod 111 params-1.sh
cassini/home/peter/bo/2021ss/bs/20210423> ./params-1.sh
/bin/bash: ./params-1.sh: Keine Berechtigung
cassini/home/peter/bo/2021ss/bs/20210423> chmod 555 params-1.sh
cassini/home/peter/bo/2021ss/bs/20210423> ./params-1.sh
cassini/home/peter/bo/2021ss/bs/20210423> ./params-1.sh Foo
Foo
cassini/home/peter/bo/2021ss/bs/20210423> ./params-1.sh Foo Bar Baz
Foo
cassini/home/peter/bo/2021ss/bs/20210423> chmod 755 params-1.sh
cassini/home/peter/bo/2021ss/bs/20210423> ./params-1.sh Pruzzel Proe
Pruzzel
cassini/home/peter/bo/2021ss/bs/20210423>
#!/bin/bash
shift
echo $1
#!/bin/bash
shift 2
echo $1
cassini/home/peter/bo/2021ss/bs/20210423> ./params-2.sh Foo Bar Baz
Bar
cassini/home/peter/bo/2021ss/bs/20210423> ./params-2.sh Foo Bar Baz Pruzzel Proe
Bar
cassini/home/peter/bo/2021ss/bs/20210423>
#!/bin/bash
shift 2
echo $1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment