1. 程式人生 > >rsync 命令詳解

rsync 命令詳解

rsync  命令介紹

rsync,remote synchronize顧名思意就知道它是一款實現遠端同步功能的軟體,它在同步檔案的同時,可以保持原來檔案的許可權、時間、軟硬連結等附加資訊。 rsync是用 “rsync 演算法”提供了一個客戶機和遠端檔案伺服器的檔案同步的快速方法,而且可以通過ssh方式來傳輸檔案,這樣其保密性也非常好,另外它還是免費的軟體。

  rsync 包括如下的一些特性:

  能更新整個目錄和樹和檔案系統;

  有選擇性的保持符號鏈鏈、硬連結、檔案屬於、許可權、裝置以及時間等;
  對於安裝來說,無任何特殊許可權要求;
  對於多個檔案來說,內部流水線減少檔案等待的延時;
  能用rsh、ssh 或直接埠做為傳輸入埠;
  支援匿名rsync 同步檔案,是理想的映象工具;

rsync 的常用用法

            如果沒有這個命令 可以 先安裝一下           yum install  rsync  
這裡一般常用的選項
rsync命令的一些選項如下:
                    -a, --archive 歸檔模式,表示以遞迴方式傳輸檔案,並保持所有檔案屬性,等於-rlptgoD
                    -r, --recursive 對子目錄以遞迴模式處理
                    -l, --links 保留軟連結
                    -p, --perms 保持檔案
許可權
                    -t, --times 保持檔案時間資訊
                    -g, --group 保持檔案屬組資訊
                    -o, --owner 保持檔案屬主資訊
                    -D, --devices 保持裝置檔案資訊
                    -v, --verbose 詳細模式輸出
                    -P, --partial保留那些因故沒有完全傳輸的檔案,以加快隨後的再次傳輸
-q --quiet
靜默模式,傳輸沒有任何資訊,即使出錯了,也沒有資訊。
                    -z, --compress 對備份的檔案在傳輸時進行壓縮處理
                    -L, --copy-links 像對待常規檔案一樣處理軟連結
                    --port=PORT 指定其他的rsync服務埠
                    --password-file=FILE 從FILE中得到密碼
–-delete:如果源端沒有此檔案,那麼目的端也別想擁有,刪除之
 –delete-excluded:專門指定一些要在目的端刪除的檔案。
rsync 命令 有很多常用的選項 ,我說幾個我常用的,

1) -a -v 選項

-a 遞迴模式,如果同步資料夾 ,這個要有的.
-v 把詳細的資訊列印在 shell 終端
舉例說明, 我同步111 這個目錄
[[email protected] ~]# ll 111/
total 44
lrwxrwxrwx. 1 root root 5 Feb 11 22:09 1.link -> 1.txt
-rw-r--r--. 1 root root 42752 Feb 11 21:54 1.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 2.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 3.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 4.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 5.txt
[[email protected] ~]# rsync 111 test
skipping directory 111
這樣是不能同步, 可以加上 -a
[[email protected] ~]# rsync-a-v 111 test
sending incremental file list
created directory test
111/
111/1.link -> 1.txt
111/1.txt
111/2.txt
111/3.txt
111/4.txt
111/5.txt
sent 43083 bytes received 114 bytes 86394.00 bytes/sec
total size is 42757 speedup is 0.99
[[email protected] ~]# ll test/111/
total 44
lrwxrwxrwx. 1 root root 5 Feb 11 22:09 1.link -> 1.txt
-rw-r--r--. 1 root root 42752 Feb 11 21:54 1.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 2.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 3.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 4.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 5.txt
此時已經把111 同步到test目錄下面了。

2) 選項 -l--links 保留軟連結

比如在111 目錄有一個1.link 的軟連線,如果我們不加 -l rsync 是預設不會同步的。
[[email protected] ~]# rsync -rv 111 test
sending incremental file list
created directory test
111/
skipping non-regular file "111/1.link"
111/1.txt
111/2.txt
111/3.txt
111/4.txt
111/5.txt
sent 43072 bytes received 111 bytes 86366.00 bytes/sec
total size is 42757 speedup is 0.99
此時發現 test/111 目錄下面 是沒有1.link 這個軟連結的。
[[email protected] ~]# ll test/111/
total 44
-rw-r--r--. 1 root root 42752 Feb 11 22:23 1.txt
-rw-r--r--. 1 root root 0 Feb 11 22:23 2.txt
-rw-r--r--. 1 root root 0 Feb 11 22:23 3.txt
-rw-r--r--. 1 root root 0 Feb 11 22:23 4.txt
-rw-r--r--. 1 root root 0 Feb 11 22:23 5.txt
如果同步的時候 加上 選項 -l 此時同步的時候, 就會把軟連線 同步過去
[email protected] ~]# rsync -rv-l111 test
sending incremental file list
created directory test
111/
111/1.link -> 1.txt
111/1.txt
111/2.txt
111/3.txt
111/4.txt
111/5.txt
sent 43081 bytes received 114 bytes 86390.00 bytes/sec
total size is 42757 speedup is 0.99
[[email protected] ~]# ll test/111/
total 44
lrwxrwxrwx. 1 root root 5 Feb 11 22:261.link -> 1.txt
-rw-r--r--. 1 root root 42752 Feb 11 22:26 1.txt
-rw-r--r--. 1 root root 0 Feb 11 22:26 2.txt
-rw-r--r--. 1 root root 0 Feb 11 22:26 3.txt
-rw-r--r--. 1 root root 0 Feb 11 22:26 4.txt
-rw-r--r--. 1 root root 0 Feb 11 22:26 5.txt

3) -p 選項 就是要保持檔案許可權

剛剛這樣同步的時候
rsync -rv -l 111 test
我 先 把 111/2.txt 許可權 更改一下
chmod 666 111/2.txt
[[email protected] ~]# ll 111/
total 44
lrwxrwxrwx. 1 root root 5 Feb 11 22:09 1.link -> 1.txt
-rw-r--r--. 1 root root 42752 Feb 11 21:54 1.txt
-rw-rw-rw-. 1 root root 0 Feb 11 21:54 2.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 3.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 4.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 5.txt
進行同步 : rsync -rv -l 111 test
[[email protected] ~]# ll test/111/
total 44
lrwxrwxrwx. 1 root root 5 Feb 11 22:32 1.link -> 1.txt
-rw-r--r--. 1 root root 42752 Feb 11 22:32 1.txt
-rw-r--r--.1 root root 0 Feb 11 22:32 2.txt
-rw-r--r--. 1 root root 0 Feb 11 22:32 3.txt
-rw-r--r--. 1 root root 0 Feb 11 22:32 4.txt
-rw-r--r--. 1 root root 0 Feb 11 22:32 5.txt
我們發現 2.txt 許可權並不是 666 而是 644 。現在來加上 -p 選項.
[[email protected] ~]# rsync -rlv-p111 test
sending incremental file list
111/1.txt
111/2.txt
111/3.txt
111/4.txt
111/5.txt
sent 43079 bytes received 108 bytes 86374.00 bytes/sec
total size is 42757 speedup is 0.99
[[email protected] ~]# ll test/
total 4
drwxr-xr-x. 2 root root 4096 Feb 11 22:36 111
[[email protected] ~]# ll test/111/
total 44
lrwxrwxrwx. 1 root root 5 Feb 11 22:32 1.link -> 1.txt
-rw-r--r--. 1 root root 42752 Feb 11 22:36 1.txt
-rw-rw-rw-. 1 root root 0 Feb 11 22:36 2.txt
-rw-r--r--. 1 root root 0 Feb 11 22:36 3.txt
-rw-r--r--. 1 root root 0 Feb 11 22:36 4.txt
-rw-r--r--. 1 root root 0 Feb 11 22:36 5.txt
此時 test/111/2.txt 就變成 許可權 就變成了666.

4) -t 選項 保持檔案的時間

這樣同步 有一個問題,檔案時間變成了 同步的時候的時間,而不是原始檔的時間。
rsync -rlv -p 111 test
[[email protected] ~]# ll test/111/
total 52
lrwxrwxrwx. 1 root root 5Feb 11 22:42 1.link -> 1.txt
-rw-r--r--. 1 root root 42752Feb 11 22:42 1.txt
-rw-rw-rw-. 1 root root 108Feb 11 22:42 2.txt
-rw-r--r--. 1 root root 70 Feb 11 22:42 3.txt
-rw-r--r--. 1 root root 0Feb 11 22:42 4.txt
-rw-r--r--. 1 root root 0Feb 11 22:42 5.txt
[[email protected] ~]# ll 111/
total 52
lrwxrwxrwx. 1 root root 5Feb 11 22:09 1.link -> 1.txt
-rw-r--r--. 1 root root 42752 Feb 11 21:541.txt
-rw-rw-rw-. 1 root root 108 Feb 11 22:40 2.txt
-rw-r--r--. 1 root root 70Feb 11 22:41 3.txt
-rw-r--r--. 1 root root 0Feb 11 21:54 4.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 5.txt
要解決這個 問題, 就是要保證原檔案的時間,同步 不能變,此時可以加上 -t 選項。
[[email protected] ~]# ll 111/
total 52
lrwxrwxrwx. 1 root root 5Feb 11 22:09 1.link -> 1.txt
-rw-r--r--. 1 root root 42752Feb 11 21:541.txt
-rw-rw-rw-. 1 root root 108Feb 11 22:40 2.txt
-rw-r--r--. 1 root root 70Feb 11 22:413.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 4.txt
-rw-r--r--. 1 root root 0Feb 11 21:54 5.txt
[[email protected] ~]# rsync -rvpl-t111 test
sending incremental file list
111/
111/1.txt
111/2.txt
111/3.txt
111/4.txt
111/5.txt
sent 43287 bytes received 114 bytes 86802.00 bytes/sec
total size is 42935 speedup is 0.99
[[email protected] ~]# ll test/111/
total 52
lrwxrwxrwx. 1 root root 5Feb 11 22:091.link -> 1.txt
-rw-r--r--. 1 root root 42752Feb 11 21:54 1.txt
-rw-rw-rw-. 1 root root 108 Feb 11 22:40 2.txt
-rw-r--r--. 1 root root 70Feb 11 22:41 3.txt
-rw-r--r--. 1 root root 0Feb 11 21:544.txt
-rw-r--r--. 1 root root 0Feb 11 21:54 5.txt
此時可以發現 ,檔案的時間資訊也同時被同步過來啦。

5) -o 保持檔案所屬主

現在 把1.txt 所屬主 改為abiao
chown abiao 1.txt
[[email protected] ~]# ll 111/
total 52
lrwxrwxrwx. 1 root root 5 Feb 11 22:09 1.link -> 1.txt
-rw-r--r--. 1 abiao root 42752 Feb 11 21:54 1.txt
-rw-rw-rw-. 1 root root 108 Feb 11 22:40 2.txt
-rw-r--r--. 1 root root 70 Feb 11 22:41 3.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 4.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 5.txt
[[email protected] ~]# rsync -rvl 111 test
sending incremental file list
111/1.link -> 1.txt
111/1.txt
111/2.txt
111/3.txt
111/4.txt
111/5.txt
[[email protected] ~]# ll test/111/
total 52
lrwxrwxrwx. 1 root root 5 Feb 11 23:02 1.link -> 1.txt
-rw-r--r--. 1 root root 42752 Feb 11 23:02 1.txt
-rw-r--r--. 1 root root 108 Feb 11 23:02 2.txt
-rw-r--r--. 1 root root 70 Feb 11 23:02 3.txt
-rw-r--r--. 1 root root 0 Feb 11 23:02 4.txt
-rw-r--r--. 1 root root 0 Feb 11 23:02 5.txt
發現 1.txt 所屬主 並沒有變成abiao ,這個時候 如果想保持檔案的所屬組,就是加一個 -o
[[email protected] ~]# rsync -rvl-o111 test
sending incremental file list
created directory test
111/
111/1.link -> 1.txt
111/1.txt
111/2.txt
111/3.txt
111/4.txt
111/5.txt
sent 43298 bytes received 114 bytes 86824.00 bytes/sec
total size is 42935 speedup is 0.99
[[email protected] ~]# ll test/111/
total 52
lrwxrwxrwx. 1 root root 5 Feb 11 23:07 1.link -> 1.txt
-rw-r--r--. 1 abiao root 42752 Feb 11 23:07 1.txt
-rw-r--r--. 1 root root 108 Feb 11 23:07 2.txt
-rw-r--r--. 1 root root 70 Feb 11 23:07 3.txt
-rw-r--r--. 1 root root 0 Feb 11 23:07 4.txt
-rw-r--r--. 1 root root 0 Feb 11 23:07 5.txt
此時 1.txt 所屬主 已經變成abiao

6) -g 保持檔案屬組

 -g, --group 保持檔案屬組資訊
還拿1.txt 說事情, 把 1.txt 的所屬組 改為dp 組
chown :dp 1.txt
[[email protected] ~]# ll 111/
total 52
lrwxrwxrwx. 1 root root 5 Feb 11 22:09 1.link -> 1.txt
-rw-r--r--. 1 abiao dp 42752 Feb 11 21:54 1.txt
-rw-rw-rw-. 1 root root 108 Feb 11 22:40 2.txt
-rw-r--r--. 1 root root 70 Feb 11 22:41 3.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 4.txt
-rw-r--r--. 1 root root 0 Feb 11 21:54 5.txt
[[email protected] ~]# rsync -rvlo 111 test
[[email protected] ~]# ll test/111/
total 52
lrwxrwxrwx. 1 root root 5 Feb 11 23:13 1.link -> 1.txt
-rw-r--r--. 1 abiaoroot 42752 Feb 11 23:13 1.txt
-rw-r--r--. 1 root root 108 Feb 11 23:13 2.txt
-rw-r--r--. 1 root root 70 Feb 11 23:13 3.txt
-rw-r--r--. 1 root root 0 Feb 11 23:13 4.txt
-rw-r--r--. 1 root root 0 Feb 11 23:13 5.txt
所屬組 並沒有變成 dp ,
此時 可以用 -g 選項.
[[email protected] ~]# rsync -rvlo -g 111 test
[[email protected] ~]# ll test/111/
total 52
lrwxrwxrwx. 1 root root 5 Feb 11 23:13 1.link -> 1.txt
-rw-r--r--. 1abiaodp42752 Feb 11 23:14 1.txt
-rw-r--r--. 1 root root 108 Feb 11 23:14 2.txt
-rw-r--r--. 1 root root 70 Feb 11 23:14 3.txt
-rw-r--r--. 1 root root 0 Feb 11 23:14 4.txt
-rw-r--r--. 1 root root 0 Feb 11 23:14 5.txt
此時1.txt 已經所屬組 已經變成了 dp

7) -z 這個就是傳輸的時候,壓縮一下。

8)--delete

 –-delete:如果源端沒有此檔案,那麼目的端也別想擁有,刪除之
tree 111/
111/
├── 1.link -> 1.txt
├── 1.txt
├── 222
├── 2.txt
├── 3.txt
├── 4.txt
└── 5.txt
[[email protected] ~]# rsync -rlv 111 test
sending incremental file list
111/1.txt
111/2.txt
111/3.txt
111/4.txt
111/5.txt
現在 我吧 111 目錄下面的 2.txt 刪除
rm -f 2.txt
此時 再一次進行同步
[[email protected] ~]# rsync -rlv --delete 111 test
sending incremental file list
deleting 111/2.txt
111/1.txt
111/3.txt
111/4.txt
111/5.txt
sent 43136 bytes received 90 bytes 86452.00 bytes/sec
total size is 42827 speedup is 0.99
此時test 已經
[[email protected] ~]# ls test/111/
1.link 1.txt 222 3.txt 4.txt 5.txt
此時已經沒有了 2.txt ,這就是 --delete 的作用。 如果原始檔刪除了,目標檔案也相應的刪除了。

9) --exclude

--exclude 同步時候排除一些檔案。
[email protected] ~]# tree 111/
111/
├── 1.link -> 1.txt
├── 1.txt
├── 222
│   └── 22.txt
├── 333
│   └── 33.txt
├── 3.txt
├── 4.txt
└── 5.txt
2 directories, 7 files
[[email protected] ~]# rsync -rvl--exclude="3.txt" --exclude="1.txt" 111/ test
sending incremental file list
created directory test
./
1.link -> 1.txt
4.txt
5.txt
222/
222/22.txt
333/
333/33.txt
sent 331 bytes received 102 bytes 866.00 bytes/sec
total size is 5 speedup is 0.01
此時發現 同步的時候可以 排除一些 檔案,防止被同步,也是對 原始檔的一種保護。

10) --delete-excluded 這個選項

這個選項 要和 --exclude 配合起來,比如我開始同步 111/ 到test/ 一開始我完全同步了。
後來 我不想 完全同步了,我不想把 1.txt 同步 ,我該 怎麼辦呢?
此時可以加上 --exclude 這個選項。 但是之前已經把 1.txt 進行了同步,所以此時 要想把目標資料夾中 刪除 1.txt , 這個時候 ,就可以加上 。 --delete-excluded 這個選項, 此時目標資料夾,就刪除了 1.txt. 看下面的例子。
第一步,完全同步。
[[email protected] ~]# rsync -rvl 111/ test/
sending incremental file list
1.txt
3.txt
4.txt
5.txt
222/22.txt
333/33.txt
第二步,不想同步 1.txt
[[email protected] ~]# rsync -rvl --exclude="1.txt" 111/ test/
sending incremental file list
3.txt
4.txt
5.txt
222/22.txt
333/33.txt
sent 372 bytes received 109 bytes 962.00 bytes/sec
total size is 5 speedup is 0.01
第三步, 此時想刪除 同步過的檔案 1.txt ,這個時候,就可以用 --delete-excluded 這個選項了, 此時就刪除了 目標檔案中,exclude 的檔案了。
[[email protected] ~]# rsync -rvl --exclude="1.txt" --delete-excluded 111/ test/
sending incremental file list
deleting 1.txt
3.txt
4.txt
5.txt
222/22.txt
333/33.txt

其實rsync 命令 是一個非常好用的命令,用法也非常豐富,當然這裡只是介紹了一些 常用的一些用法.


分享快樂,留住感動。


相關推薦

rsync命令rsync用ssh隧道方式同步

命令 針對 添加 ssh root res 方式 author 設備文件 對待 ● rsync格式安裝命令 yum install -y rsync與scp的區別:scp復制為完全覆蓋,rsync為增量同步,只同步修改過的數據。rsync命令格式如下: rsync 選項

rsync命令

lis 出現 oot 密碼登錄 算法 com 用戶組 compare 接收 安裝yum install rsync rsync 有六種不同的工作模式。rsync [OPTION]... SRC DEST rsync [OPTION]... SRC [USER@]host

rsync 命令

rsync  命令介紹 rsync,remote synchronize顧名思意就知道它是一款實現遠端同步功能的軟體,它在同步檔案的同時,可以保持原來檔案的許可權、時間、軟硬連結等附加資訊。 rs

Linux下的rsync命令(受不了網上以訛傳訛的翻譯)

rsync是一款UNIX系統中的開源工具,提供增量的檔案傳輸功能。 rsync採用GNU GPL許可證。 rsync的最新版本是2015.12.21釋出的3.1.2。 1.rsync工具的組成 rsync檔案,實現遠端檔案複製的命令rsync.conf檔案,在Daemon模

rsync同步命令

一、rsync命令的解釋sync(Synchronize,即“同步”)為UNIX作業系統的標準系統呼叫,功能為將核心檔案系統緩衝區的所有資料(也即預定將通過低階I/O系統呼叫寫入儲存介質的資料)寫入儲存介質(如硬碟)。sync是一個linux同步命令,含義為迫使緩衝塊資料立即寫盤並更新超級塊。在linux系統

Linux下使用rsync進行資料備份的命令

對於運維人員來說,資料備份是最重要的工作之一,rsync就是一款通過網路備份重要資料的工具/軟體。 sync同樣是一個在類Unix和Window系統上通過網路在系統間同步資料夾和檔案的網路協議,它可以複製或者顯示目錄並複製檔案。rsync預設監聽TCP 873埠,通過遠端shell如rsh和ssh

tar命令

pan 詳解 time border 設備 lin bsp force names 解壓到指定目錄 tar -zxvf flash_player_npapi_linux.x86_64.tar.gz -C mmtar -zxvf flash_player_npapi_linu

Linux下安裝軟件命令

代碼包 相關信息 make bin 一個 軟件包 輸入 -i bin文件 Linux下軟件安裝方法總結:一、rpm包安裝方式步驟:1、找到相應的軟件包,比如soft.version.rpm,下載到本機某個目錄;2、打開一個終端,su -成root用戶;3、cd soft.v

Docker常用命令

nbsp 詳解 .cn 本地 test 並且 www 更多 top docker ps 查看當前正在運行的容器 docker ps -a 查看所有容器的狀態 docker start/stop id/name 啟動/停止某個容器 docker attach id 進

linux下cat命令

forever ron localhost root sta testing 幫助 查看 一點 1、cat 顯示文件連接文件內容的工具; cat 是一個文本文件查看和連接工具。查看一個文件的內容,用cat比較簡單,就是cat 後面直接接文件名。 比如: de>[[

Linux:at命令

計時 osi 執行 inux days pan 必須 man 一個 at命令 at命令為單一工作調度命令。at命令非常簡單,但是在指定時間上卻非常強大 語法 at [選項] time at > 執行的命令 ctrl+d 選項 -m :當指定的任務被

grep命令

命令詳解 顯示 不包含 文件 開頭 文件中查找 時間 匹配 nbsp grep命令 1、grep "li qq" * 在的有文件中查找li qq文件。 2、grep -c "file" a 在a文件中有多少行匹配到file。 3、grep -n "

linux 之awk命令

數學函數 mat loop 多次 finished 數組結構 save pre 新的 awk是一種程序語言,對文檔資料的處理具有很強的功能。awk名稱是由它三個最初設計者的姓氏的第一個字母而命名的: Alfred V. Aho、Peter J. We i n b e rg

【轉】linux之cp/scp命令+scp命令

特殊 是否 用戶登錄 usr 指定 highlight 顯示 檔案 三種 linux之cp/scp命令+scp命令詳解 名稱:cp 使用權限:所有使用者 使用方式: cp [options] source dest cp [options] source

Linux下同步工具inotify+rsync使用

server linux 通道 主機 Linux下同步工具inotify+rsync使用詳解 Posted on 2014-12-12 | In Linux | 9 | Visitors 4381. rsync1.1 什麽是rsyncrsync是一個遠程數據同步工具,可通過LAN/WAN

xargs命令

文件名 過程 介紹 pri .sh 例如 接收 替換字符 welcom xargs命令是把接收到的數據重新格式化,再將其作為參數提供給其他命令,下面介紹xargs命令的各種使用技巧 一、將多行輸入轉換成單行輸入: [[email protected]/* */

Linux netstat命令,高級面試必備

bytes tool head osi ngs 進行 pen 通信 詳細信息 簡介 Netstat 命令用於顯示各種網絡相關信息,如網絡連接,路由表,接口狀態 (Interface Statistics),masquerade 連接,多播成員 (Multicast Mem

Linux下的tar壓縮壓縮命令

命令 .tar.gz 需要 logo 意思 追加 lin 產生 ron tar -c: 建立壓縮檔案-x:解壓-t:查看內容-r:向壓縮歸檔文件末尾追加文件-u:更新原壓縮包中的文件 這五個是獨立的命令,壓縮解壓都要用到其中一個,可以和別的命令連用但只

linux top 命令

ctrl+ 一次 所有 使用方法 ase 隱藏 統計 ini 前臺 top命令是Linux下常用的性能分析工具,能夠實時顯示系統中各個進程的資源占用狀況,類似於Windows的任務管理器。下面詳細介紹它的使用方法。top - 01:06:48 up 1:22, 1 user

Shell find命令

一個 打印 文件訪問 perm mtime -o 多次 所有者 cut 查找文件find ./ -type f查找目錄find ./ -type d查找名字為test的文件或目錄find ./ -name test查找名字符合正則表達式的文件,註意前面的‘.*’(查找到的文