I run this zsh chained command in my terminal:
cd /path/to/backups/pod3 && rm -rf ./*(Om[1,-10])
This works fine and removes the appropriate directories as expected.
However, when I put that in a script, I get this error:
syntax error near unexpected token `('
I did some research and it seems I need to set this in my shell script:
However, after I add that line at the top of the script, it throws its own error.
setopt: command not found
So I am not sure what I am doing wrong here and how to fix this.