<Poprzedni | Spis treści | Następne>
Przydatne opcje i przykłady
Here are some of the commonly used options (the short option and the equivalent long option) for cp:
Table 4-4: cp Options
Opcja Znaczenie
Opcja Znaczenie
-a, --archive Copy the files and directories and all of their attributes,
including ownerships and permissions. Normally, copies take on the default attributes of the user performing the copy.
-ja, --interaktywny Przed nadpisaniem istniejącego pliku należy poprosić użytkownika o podanie
potwierdzenie. Jeśli ta opcja nie jest określona, cp będzie po cichu nadpisywać pliki.
-R, - rekurencyjny Recursively copy directories and their contents. This
opcja (lub tzw -a option) is required when copying directories.
-u, --update When copying files from one directory to another, only
copy files that either don't exist, or are newer than the existing corresponding files, in the destination directory. This is useful when copying large numbers of file as it skips over files that don't need to be copied.
-v, --gadatliwy Display informative messages as the copy is
wykonane.
Table 4-5: cp Examples
Wyniki polecenia
Wyniki polecenia
cp plik1 plik2 Skopiuj file1 do file2. If file2 istnieje, jest nadpisywane
o treści file1. Jeśli file2 nie istnieje, jest tworzony.
cp -i plik1 plik2 Tak samo jak powyżej, z tą różnicą, że jeśli file2 istnieje, użytkownik jest
zostanie wyświetlony monit przed nadpisaniem.
cp plik1 plik2 katalog1 Skopiuj file1 i file2 do katalogu dir1. dir1 must already exist.
cp dir1/* dir2 Using a wildcard, all the files in dir1 are copied
najnowszych dir2. dir2 must already exist.
cp -r kierunek 1 kierunek 2 Copy the contents of directory dir1 do katalogu
dir2. If directory dir2 does not exist, it is created and, after the copy, will contain the same contents as directory dir1.
Jeśli katalog dir2 does exist, then directory dir1 (and its contents) will be copied into dir2.