核心實用程式,針對文本及檔案操作。涉及到102條linux指令。
指令清單:cp、install、ln、mv、ls、echo……
常見選項
1.退出狀态
2.備份選項
cp, install, ln, mv
短選項 | 長選項 | 注解 |
---|---|---|
-b | '--backup'[=method] | 當某個檔案存在被移動(mv)、覆寫的情況時,如何備份的指定選項。 短選項不接受任何參數,預設是“--backup=existing“。 |
-S SUFFIX | --suffix=SUFFIX | 與“-b”同時使用,添加到檔案名中。 |
當不指定“method”,有點複雜,建議指定。參數接受“唯一性縮寫”、多字元表示,參數如下:
METHOD參數 | |
---|---|
none off | 永不備份 |
numbered t | 總是進行編号備份 |
existing nil | 已有的編号備份,其他的簡單備份 |
simple never | 簡單備份 |
3.目标目錄
-T File | --no-target-directory | 指定普通檔案,父目錄必須是存在的。格式:install -T large.cnf /etc/my.cnf 效果,就像複制後重命名,目标在最後且是個普通檔案。 |
-t DIR | --target-directory=DIR | 指定目錄檔案,該目錄必須存在。格式:install -t /etc my.cnf 像是複制進去一樣,目标在前,且是目錄。 |
例子,使用“-T”:
[root@right mag]# ll
total 0
drwxr-xr-x. 2 root root 6 Dec 30 11:11 back
drwxr-xr-x. 2 root root 6 Dec 30 11:11 mag
[root@right mag]# mv -T mag back
mv: overwrite ‘back’? y
[root@right mag]# ll
total 0
drwxr-xr-x. 2 root root 6 Dec 30 11:11 back
[root@right mag]# ll
total 0
drwxr-xr-x. 2 root root 6 Dec 30 11:11 back
drwxr-xr-x. 2 root root 6 Dec 30 11:17 mag
[root@right mag]# mv -t mag back
[root@right mag]# ll
total 0
drwxr-xr-x. 3 root root 17 Dec 30 11:17 mag
[root@right mag]# ls mag/
back
[root@right mag]# ll
total 0
drwxr-xr-x. 2 root root 6 Dec 30 11:11 back
drwxr-xr-x. 2 root root 6 Dec 30 11:20 mag
[root@right mag]# mv back mag
[root@right mag]# ll
total 0
drwxr-xr-x. 3 root root 17 Dec 30 11:20 mag
[root@right mag]# ls mag/
back