You should avoid setting the PATH
variable. This is used by your shell to find valid commands, setting it to /tmp/
is going to prevent the script from being able to find the rm
and cp
commands altogether.
You can accomplish what you want with the following find
command:
find /tmp -not -name '*.csv' -not -path /tmp -exec rm -vr {} \;
Note: this will delete any subdirectories under /tmp as well. If you do not want this you must change to:
find /tmp -not -name '*.csv' -type f -exec rm -v {} \;
Another note: This will still recurse into the subdirectories and delete the files in them. If you do not want this you can use the maxdepth
argument:
find /tmp -not -name '*.csv' -maxdepth 1 -type f -exec rm -v {} \;
Extra note: I would never run a find ... -exec
command that you find online without verifying it will do what you need it to do first. You should run:
find /tmp -not -name '*.csv' -not -path /tmp
And verify it is finding only the files you want before adding the -exec rm -vr {} \;
bit.
run_spark_local
?shopt -s extglob
./tmp
could have adverse consequences on other programs running on the system.