The below command recursively deletes all but 104.tar file under /tmp/CURRENT folder.
find /tmp/CURRENT/ -type f ! -name '104.tar' -exec rm -rf {} + It however, does not recursively delete any sub-folders under /tmp/CURRENT.
if I give -type d it may help but I don't want a separate command. My requirement is to delete both files and folders with the same single command which I tried below but it did not help.
find /tmp/CURRENT/ -type f -type d ! -name '104.tar' -exec rm -rf {} + If I don't specify -type option at all, then the command delete the entire /tmp/CURRENT folder rather than its contents !
Note: MY OS is Sun Solaris Sparc.
Can you please suggest ?
rm -f. You only need-rto make it recursive and remove directories.