ZhangZhihui's Blog  
2022-04-26 11:27PM
[scnzzh:/home/scnzzh/aaa]$>find -P /home/scnzzh/aaa/prf_dashboard -maxdepth 2 -name "profile_qlikreporting_data_*_*.tar.gz"
/home/scnzzh/aaa/prf_dashboard/LB/profile_qlikreporting_data_LB_2022.tar.gz
/home/scnzzh/aaa/prf_dashboard/MAU/profile_qlikreporting_data_MAU_2022.tar.gz
/home/scnzzh/aaa/prf_dashboard/archive/profile_qlikreporting_data_LB_202204.tar.gz

2022-04-26 11:27PM
[scnzzh:/home/scnzzh/aaa]$>find -P /home/scnzzh/aaa/prf_dashboard -not -path "*/archive/*" -maxdepth 2 -name "profile_qlikreporting_data_*_*.tar.gz"
find: warning: you have specified the -maxdepth option after a non-option argument -not, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

/home/scnzzh/aaa/prf_dashboard/LB/profile_qlikreporting_data_LB_2022.tar.gz
/home/scnzzh/aaa/prf_dashboard/MAU/profile_qlikreporting_data_MAU_2022.tar.gz

2022-04-26 11:28PM
[scnzzh:/home/scnzzh/aaa]$>find -P /home/scnzzh/aaa/prf_dashboard -maxdepth 2 -name "profile_qlikreporting_data_*_*.tar.gz" -not -path "*/archive/*"
/home/scnzzh/aaa/prf_dashboard/LB/profile_qlikreporting_data_LB_2022.tar.gz
/home/scnzzh/aaa/prf_dashboard/MAU/profile_qlikreporting_data_MAU_2022.tar.gz

 

-P Never follow symbolic links. This is the default behaviour. When find examines or prints information about files, and the file is a symbolic link, the information used shall be taken from the properties of the symbolic link itself.

 

Using the -not Operator

 The find command also provides the -not operator. We can use it to exclude a directory from a search path:
$ find . -type f -not -path '*/mp3/*'

Using the ! Operator

 One more way to exclude a directory is to use the ! operator with the find command:
$ find . -type f ! -path '*/txt/*'

posted on 2022-04-26 11:26  ZhangZhihuiAAA  阅读(170)  评论(0编辑  收藏  举报