我試圖運行一個自動洗掉腳本來釋放遠程服務器上的空間。
我想使用的命令是:
find . -atime 30 -mtime 30 -type f -delete
我想要的是同時捕獲哪些檔案被成功洗掉,哪些檔案因為訪問問題而失敗。我應該怎樣做呢? 我想下面這個命令可能只處理失敗的檔案,但我不確定。
find . -atime 30 -mtime 30 -type f -delete 2> failed_deletions.txt
uj5u.com熱心網友回復:
find out of the box does not print the files it processes. 如果你想列出這些檔案,請在-delete之前添加一個-print或-ls。
這顯然會列印出它所處理的所有檔案,包括由于某種原因未能洗掉的檔案。
將標準輸出重定向到一個不同的檔案應該是很容易發現的;command >stderr 2>stdout
uj5u.com熱心網友回復:
性能較差,但應該能達到你想要的效果:
find . -atime 30 -mtime 30 -type f -exec rm -v {}; > successful.txt 2> failed.txt
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/318100.html
標籤:
下一篇:明確鏈接到libc(-lc)。
