Posted onEdited onInShellScriptViews: Disqus: Symbols count in article: 470Reading time ≈1 mins.
ShellScript-tar and delete Batch
這篇介紹ShellScript-tar and delete Batch。
Examples
1 2 3 4 5 6 7 8 9
date=`date"+%Y-%m-%d"` #tar file for name have "_" "find /usr/local/tomcat/logs/ -name "_*.log" -print0 |xargs -0 tar -czvf $date-testlog.tar.gz {} \;" memo:找出logs底下_開頭的.log檔案,將檔案s壓縮成2021-06-02-testlog.tar.gz
#delete file for name have "_" "find /usr/local/tomcat/logs/ -name "_*.log" -exec rm -f {} \; " memo:找出logs底下_開頭的.log檔案,將檔案s刪除掉