I want to delete all the files in a folder apart from my LOG directory and my reports directory. Is there a way to do that in Linux terminal using rm command ?
I want to delete all the files in a folder apart from my LOG directory and my reports directory.
rm -rf !(LOG|reports)
Make sure that you have extglob
option enabled:
shopt -s extglob
$rm -rf [your directory path to delete]
此命令将删除所选目录以及其中的所有文件和文件夹。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.