The following find command filters the files and directories starting with dot symbol.
find $PWD \( -name '.*' -prune \) -o -print
Where as adding the "-type f" condition does not filter files starting with dot.
find $PWD \( -name '.*' -type f -prune \) -o -print # this does not work
How to prune only files starting with dot
EDIT 1: Clarification on "Does not work"
The command lists the file starting with the dot operator. Later found that it was a symbolic link to another file(which does not start with dot). Tried using -L (follow symbolic links) option like below which still listed the symbolic link file starting with dot.
find -L $PWD \( -name '.*' -type f -prune \) -o -print
您似乎对“ prune”的含义有些困惑: -prune
表示不属于子目录 ,因此对于-type f
,这实际上没有任何意义。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.