
我想找到一個不名為“STDF”的資料夾,然後將其存檔。
find /a/b/c -mindepth 1 -maxdepth 1 ! -path "STDF" -exec /usr/bin/gzip '{}' \;
上面的命令不起作用。
答案1
你可以試試
find /where/to/look/ -type d -not -name STDF
找到資料夾
既然您提到了您收到的錯誤,我發現您正在使用 gzip 來壓縮資料夾,但您不能這樣做。看著這個答案有關如何壓縮資料夾的更多信息
答案2
該gzip
命令需要r
標誌。
find /a/b/c -mindepth 1 -maxdepth 1 -type d ! -name '*STDF*' -exec sh -c 'tar -zcvf "${1}".tar.gz "$@"' _ {} \;