How do I remove certain files from a different directory than $PWD using the bash shell script.
Looking at the documentation for rm, it appears that rm only works in $PWD.
Am I forced to use this method:
oDir=$PWD
cd directorytoremovefiles
rm files
cd oDir
rm certainly does work for deleting files in another directory.
Whatever gave you that idea from the man page, I certainly hope it's not this:
rm removes each specified file. By default, it does not remove directories.
The documentation you refer to, talks only about having write & execute permission to the directory you are deleting from.
So you only need:
rm directorytoremovefiles/files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With