[英]Delete particular files in all subdirectories of a directory in linux
我想從目錄及其所有子目錄中刪除所有不是“.wav”格式的音頻文件。
我的腳本在這里不起作用 -
for file in /home/deepthought/Music/genres/*/; do rm $file not in *.wav; done
什么是正確的例行程序?
采用
find /home/deepthought/Music/genres -not -name '*.wav' -print
列出文件並驗證它們是您要刪除的文件。 然后
find /home/deepthought/Music/genres -not -name '*.wav' -delete
請改用find
命令,
find /home/deepthought/Music/genres -not -name "*.wav" -type f -delete
嘗試使用-exec命令行查找命令,如:
find /home/deepthought/Music/genres -type f -not -name "*.wav" -exec rm -f {} \;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.