Hi,
I need to delete all files from a directory except for one folder:
The directory with all of the files I want to delete:
/home/user
The directory I want to keep:
/home/user/backup
/home/user has a bunch of files and folders in it that I want to blow away
/home/user/backup has a bunch of files and folders that would make me sad if I blew them away (i.e., I want to keep the backjup directory and all of the files in it).
I created a test directory structure and touched a few files in each and used "rm -rf /home/user/*" thinking it would balk because the child directory wasn't empty but it just wiped everything out.
Any help would be greatly appreciated.
Thanks!
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.