How to use exclude option in rm -rf command
____________________________________________________________________________________\
Check this out :
http://www.linuxquestions.org/ questions/red-hat-31/does-rm- command-has-a-option-exclude- 623091/
___________________________________________________________________________________
____________________________________________________________________________________\
Check this out :
http://www.linuxquestions.org/
___________________________________________________________________________________
You can use following tricks to exclude files
Using Bash extglob ( not it will exclude file1.txt, I've used ls command for demo )
rahul@lappy:/tmp/test$ ls -rlht total 0 -rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file1.txt -rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file5.txt -rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file4.txt -rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file3.txt -rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file2.txt rahul@lappy:/tmp/test$ shopt extglob extglob on rahul@lappy:/tmp/test$ ls -rlht !(file1.txt) -rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file5.txt -rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file4.txt -rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file3.txt -rw-rw-r-- 1 rahul rahul 0 Dec 22 15:36 file2.txt
Using find command
find . -type f ! -iname 'file1.txt' -exec ls -lrt {} \;
No comments:
Post a Comment