I want to do something like this in a bash script. I am using bash 4.1.10 .
Works well (and as expected) from the shell itself. It deletes 3 desired folders, leaving all the others untouched.
When I put it in a script, something unwanted happens. For example, my script:
#!/bin/bash set -x VAR="folder1,folder2,folder3" rm -rf /some/path/{$VAR}
When I execute this script, folders are not deleted.
I think this is due to some unwanted quotation happening. Output from script using #!/bin/bash -x :
rm -rf '/some/path/{folder1,folder2,folder3}'
which, of course, cannot be successful because of the marks. '
How can I make this work in my script?
bash escaping brace-expansion
Rolling
source share