[ligang@centos6 test]$ ll total 4 -rw-r--r-- 1 ligang trainning 0 Mar 10 00:35 haha.txt drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:19 test1 [ligang@centos6 test]$ cp haha.txt test1/ [ligang@centos6 test]$ ll test1/ total 4 -rw-r--r-- 1 ligang trainning 0 Mar 10 00:36 haha.txt -rw-r--r-- 1 ligang trainning 7 Mar 10 00:07 log1.txt -rw-r--r-- 1 ligang trainning 0 Mar 10 00:10 log2.txt [ligang@centos6 test]$ cp haha.txt test1/ [ligang@centos6 test]$ ll test1/ total 4 -rw-r--r-- 1 ligang trainning 0 Mar 10 00:36 haha.txt -rw-r--r-- 1 ligang trainning 7 Mar 10 00:07 log1.txt -rw-r--r-- 1 ligang trainning 0 Mar 10 00:10 log2.txt
(2)cp不能直接把文件夾復(fù)制給另外一個(gè)文件夾,否者要加參數(shù)-rf。如果要把一個(gè)文件夾下內(nèi)容復(fù)制給另外一個(gè)文件夾則用dir/*
[ligang@centos6 test]$ cp test2/ test1 cp: omitting directory `test2/' [ligang@centos6 test]$ cp -rf test2/ test1 [ligang@centos6 test]$ ll total 12 -rw-r--r-- 1 ligang trainning 5 Mar 10 00:37 haha.txt drwxr-xr-x 3 ligang trainning 4096 Mar 10 00:42 test1 drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:40 test2 [ligang@centos6 test]$ mkdir test3 [ligang@centos6 test]$ cp -af test3 test1 [ligang@centos6 test]$ ll test1 total 16 -rw-r--r-- 1 ligang trainning 5 Mar 10 00:37 haha.txt -rw-r--r-- 1 ligang trainning 7 Mar 10 00:07 log1.txt -rw-r--r-- 1 ligang trainning 0 Mar 10 00:10 log2.txt drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test2 drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test3 [ligang@centos6 test]$ mkdir test4 [ligang@centos6 test]$ c test4 -bash: c: command not found [ligang@centos6 test]$ cd test4 [ligang@centos6 test4]$ touch test.txt [ligang@centos6 test4]$ cd .. [ligang@centos6 test]$ cp -rf test4/ test1 [ligang@centos6 test]$ ll test1 total 20 -rw-r--r-- 1 ligang trainning 5 Mar 10 00:37 haha.txt -rw-r--r-- 1 ligang trainning 7 Mar 10 00:07 log1.txt -rw-r--r-- 1 ligang trainning 0 Mar 10 00:10 log2.txt drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test2 drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test3 drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:45 test4 [ligang@centos6 test]$ cp test4/* test1 [ligang@centos6 test]$ ll test1 total 20 -rw-r--r-- 1 ligang trainning 5 Mar 10 00:37 haha.txt -rw-r--r-- 1 ligang trainning 7 Mar 10 00:07 log1.txt -rw-r--r-- 1 ligang trainning 0 Mar 10 00:10 log2.txt drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test2 drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test3 drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:45 test4 -rw-r--r-- 1 ligang trainning 0 Mar 10 00:45 test.txt
9linux命令,touch
功能:用來修改文件時(shí)間戳linux命令,或者新建一個(gè)不存在的文件。
-r把指定文檔或目錄的日期時(shí)間,統(tǒng)統(tǒng)設(shè)成和參考文檔或目錄的日期時(shí)間相同。
-t使用指定的日期時(shí)間,而非現(xiàn)在的時(shí)間。格式: [[CC]YY]MMDDhhmm[.SS]
上一個(gè)教程:Linux中find命令的使用詳解(上)
下一個(gè)教程:linux的zip命令詳解