next up previous contents
Next: xargs Up: 外部命令 Previous: getopt   Contents

find

尋找檔案用的程式命令,
    find . -name "regex"
    find / -type d 找directory
                 f 找plain file
                 l 找symbolic link
                 p 找named pipe file
                 b 找block device
                 c 找char device
    find . -perm 755
    find / -user cyril
    gzip `find . \! -name '*.gz' -print`

    not ! 有的shell要加\ 因為!有特別意義,例如bash表示取回以前的命令。

    find -name -type -o -name
在script中很多時候都是脫逃字元問題,常看到\時都要想到這是脫逃字元。 在script中 ()也有特別意義表示喚起另一個subshell來執行所以碰到()時也要用 脫逃字元。或者合sed awk一起使用時也是一樣的道理。

Cyril Huang 2002-06-14