0
我正在練習unix find
命令並根據權限進行過濾。這是對我的做法目錄的ls -al
樣子:Linux的管道結果查找perm到ls顯示衝突的輸出
[[email protected] ~]$ ls -al
total 44
drwx------. 8 tom tom 4096 Dec 13 09:08 .
drwxr-xr-x. 7 root root 63 Nov 5 16:38 ..
-rw-------. 1 tom tom 9547 Dec 15 08:16 .bash_history
-rw-r--r--. 1 tom tom 18 Oct 26 00:36 .bash_logout
-rw-r--r--. 1 tom tom 193 Oct 26 00:36 .bash_profile
-rw-r--r--. 1 tom tom 231 Oct 26 00:36 .bashrc
drwxrwxr-x. 2 tom tom 21 Dec 12 22:14 chattrdir
-rw-rw-r--. 1 tom tom 0 Dec 13 09:03 file1
-rw-rw-r--. 1 tom tom 0 Dec 13 09:03 file2
drwxr-xr-x. 2 tom tom 4096 Dec 11 14:36 fileext
-rw-------. 1 tom tom 164 Dec 14 09:25 .lesshst
drwxr-xr-x. 4 tom tom 37 Dec 20 2015 .mozilla
drwxrw----. 3 tom tom 18 Dec 8 20:20 .pki
drwx------. 2 tom tom 24 Nov 7 09:51 .ssh
-rw-------. 1 tom tom 3639 Dec 8 20:56 .viminfo
drwxrwxr-x. 2 tom tom 4096 Dec 8 21:26 wildcard
我做find命令來搜索基於權限:
[[email protected] ~]$ find . -maxdepth 1 -perm /004
./.bash_logout
./.bash_profile
./.bashrc
./.mozilla
./chattrdir
./file1
./file2
./fileext
./wildcard
下一頁,看看這些的確是其擁有的唯一文件閱讀「其他」的權限位設置,我管道輸出到ls
:
[[email protected] ~]$ find . -maxdepth 1 -perm /o+r | ls -al
total 44
drwx------. 8 tom tom 4096 Dec 13 09:08 .
drwxr-xr-x. 7 root root 63 Nov 5 16:38 ..
-rw-------. 1 tom tom 9584 Dec 15 08:23 .bash_history
-rw-r--r--. 1 tom tom 18 Oct 26 00:36 .bash_logout
-rw-r--r--. 1 tom tom 193 Oct 26 00:36 .bash_profile
-rw-r--r--. 1 tom tom 231 Oct 26 00:36 .bashrc
drwxrwxr-x. 2 tom tom 21 Dec 12 22:14 chattrdir
-rw-rw-r--. 1 tom tom 0 Dec 13 09:03 file1
-rw-rw-r--. 1 tom tom 0 Dec 13 09:03 file2
drwxr-xr-x. 2 tom tom 4096 Dec 11 14:36 fileext
-rw-------. 1 tom tom 164 Dec 14 09:25 .lesshst
drwxr-xr-x. 4 tom tom 37 Dec 20 2015 .mozilla
drwxrw----. 3 tom tom 18 Dec 8 20:20 .pki
drwx------. 2 tom tom 24 Nov 7 09:51 .ssh
-rw-------. 1 tom tom 3639 Dec 8 20:56 .viminfo
drwxrwxr-x. 2 tom tom 4096 Dec 8 21:26 wildcard
你看到下面的文件做不是已經讀取權限爲他人設定,即使我只希望它做對他人讀取權限位設置的文件:
-rw-------. 1 tom tom 9584 Dec 15 08:23 .bash_history
rw-------. 1 tom tom 164 Dec 14 09:25 .lesshst
drwxrw----. 3 tom tom 18 Dec 8 20:20 .pki
drwx------. 2 tom tom 24 Nov 7 09:51 .ssh
-rw-------. 1 tom tom 3639 Dec 8 20:56 .viminfo
如何可能這些文件過程中出現的輸出呢?我只將根據我的查找搜索可讀的文件傳送給ls
命令,ls
顯示它們不可讀。
謝謝!很高興給出-exec選項的額外信息來獲得我想要的。 – Tom
不客氣 – hek2mgl