Skip to main content
dont -> don't
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264

Just to give a different answer, you can use the default behavior of rm that it wontwon't delete folders,:

mkdir tmp && mv file.txt tmp  # create tmp dir and move files there
rm                            # delete all other files
mv tmp/* . && rm -rf tmp      # move all files back and delete tmp dir

Just to give a different answer, you can use the default behavior of rm that it wont delete folders,

mkdir tmp && mv file.txt tmp  # create tmp dir and move files there
rm                            # delete all other files
mv tmp/* . && rm -rf tmp      # move all files back and delete tmp dir

Just to give a different answer, you can use the default behavior of rm that it won't delete folders:

mkdir tmp && mv file.txt tmp  # create tmp dir and move files there
rm                            # delete all other files
mv tmp/* . && rm -rf tmp      # move all files back and delete tmp dir
Source Link
Nithin
  • 231
  • 3
  • 7

Just to give a different answer, you can use the default behavior of rm that it wont delete folders,

mkdir tmp && mv file.txt tmp  # create tmp dir and move files there
rm                            # delete all other files
mv tmp/* . && rm -rf tmp      # move all files back and delete tmp dir