1

I'm trying to delete all the files contained in multiple folders.

I'm trying to have a code working like this:

#!/bin/sh
cd path1                            rm -R *
cd path2                            rm -R *
....
cd pathN                            rm -R *

But it doesn't seems to work. It's possible to use the cd for that?

Thanks

1 Answers1

1

You can give multiple files/directories in rm command:

rm -rf path1 path2 path3 pathN

Please note, if you use -rf option, it will delete everything under the path.

Homer
  • 424
  • 3
  • 7
  • Thanks a lot for the answer. But it seems that it will delete the folder of the path not only the content of it – Carlo Mattarello Sep 24 '20 at 07:43
  • 1
    If you want to keep `path1`, and delete everything in it, use it like `rm -rf path1/* path2/* path3/* pathN/*` – Homer Sep 24 '20 at 14:28