Ok, I just did something similar, I use different types of LS all the time at work to get lists of filenames.
I just recently did one that does an exclude, it worked when ran, so I saved it as a RUNTOREFRESH.sh and put it in crontab to run every hour on the 58th minute.
Now it worked when I ran it, but the script fails returning this error...
RUNTOREFRESH.sh: 1: Syntax error: "(" unexpected
The script is...
ls -RA1 !(Archive) > ./result.csv
It doesn't like the exclude, but I am unsure why. It accepts it if ran as a normal command directly.
I am obviously noob to scripting and really I just started doing some small stuff like file move's and listing > files because I was doing some much manually at work because no one knows anything about linux at all. If someone could give a quick reasoning as to why its failing as well I would really appreciate it.
I just recently did one that does an exclude, it worked when ran, so I saved it as a RUNTOREFRESH.sh and put it in crontab to run every hour on the 58th minute.
Now it worked when I ran it, but the script fails returning this error...
RUNTOREFRESH.sh: 1: Syntax error: "(" unexpected
The script is...
ls -RA1 !(Archive) > ./result.csv
It doesn't like the exclude, but I am unsure why. It accepts it if ran as a normal command directly.
I am obviously noob to scripting and really I just started doing some small stuff like file move's and listing > files because I was doing some much manually at work because no one knows anything about linux at all. If someone could give a quick reasoning as to why its failing as well I would really appreciate it.