bashscriptingmobaxterm

Remove the content of multiple folders with a bash script in Moba


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


Solution

  • 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.