next | next | up | down | Inhalt | Uebungen | Complete | Kommentar

all, section 3.8.

3.8.  Kopieren

Kopieren von Dateien (cp)

$ cp alteDatei neueDatei        # Eine Datei kopieren.
$ cp alteDatei... katalog       # mehrere Dateien in einen Katalog

Kopieren von Bäumen (cpio, tar)

$ ls | cpio -oc > /tmp/cpio.out     # Dateien archivieren.
$ cpio -ict < /tmp/cpio.out         # I.-V. eines Archivs zeigen.
$ cpio -icdum < /tmp/cpio.out       # Archiv einspielen.
$ cd alt; \     # Dateibaum als Links kopieren.
> find . -depth -print | cpio -pdl neuerPfad

$ tar cf /tmp/x Soelim
$ tar cf - Soelim | ( cd /tmp && tar xf - )
$ ls -ld /tmp/S*
drwxr-xr-x   2 bischof  wheel        1024 Apr  4 15:19 /tmp/Soelim
$ tar cf - Soelim | ( cd /tmp;  tar xf - )
tar cf tar.out pfad...     # Dateien und Bäume archivieren.
$ tar tf tar.out           # Inhaltsverzeichnis eines Archivs zeigen.
$ tar xf tar.out muster...         # Archiv einspielen.
$ ( cd alt && tar cf -. ) | \     # Dateibaum kopieren.
> ( cd neu && tar xf - )

Archive mit absoluten Pfaden sind nicht sehr praktisch.

Datenstrom byteweise betrachten: (dd)

$ dd < ein > aus bs=30k       # Kopieren.

dd kopiert, wobei fixe Satzlängen und Anzahl von Sätzen kontrolliert werden können. Es gibt viele Optionen mit einer sehr veralteten Syntax, zum Beispiel:

bs=10k      in Stücken von 10 KB
skip=6      zuerst 6  10KB-Blöcke überspringen
seek=8      zuerst 8 10KB-Blöcke in Ausgabe überspringen
count=20    bis zu 20 10KB-Blöcke kopieren
conv=sync   Ausgabe ist Vielfaches von 10KB
dd ist das einzige Programm, das aus binärer Information nach Position Bytes extrahieren kann.

hello.c:

 1      void main(void){ printf("hello\n"); exit(0); }

$ make hello
cc   hello.c  -o hello
$ hello
hello
$ strings -o hello
   8060 The kernel support for the dynamic linker is not present to run this program.
   8140 __dyld_make_delayed_module_initializer_calls
   8185 hello
$ dd bs=1 if=hello of=x count=5 skip=8185
5+0 records in
5+0 records out
$ cat x
hello
$ dd bs=1 if=hello of=1 count=8185
8185+0 records in
8185+0 records out
$ echo HELO > 2
$ dd bs=1 if=hello of=3 skip=8190
23390+0 records in
23390+0 records out
$ cat 1 2 3 > x
$ chmod +x x
$ x
HELO


back | next | up | down | Inhalt | Uebungen | Complete | Kommentar


Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).

Last modified 03/July/97