I have this little bash script :
#!/bin/bash
PATH1="/home/user100/files"
CMD1=$(find . -type f -iname "*.sh" -exec rm -fr {} +;)
cd $PATH1
$CMD1
If I run one by one the commands they are all executed successfully, if I run the script it just does nothing at all.
Any help or idea would be appreciated.
CMD1
variable? Replace$CMD1
in the last line withecho "$CMD1"
. Probably you are doing something very wrong.../
or~
..
, your cwd, and removes any .sh files in there. (Being as find recurses, and you picked files and not directories, the -r in remove is junk.) Anyway, that find returns nothing - it does the commands, but there is no data from stdout. So CMD1 is empty. Then you cd to another directory, and run an empty command. What exactly did you intend it to do?