I have a simple segment of code that works when I run it on it's own, although it doesn't work when it is called from a file.
Code below:
for files in *; do echo ${files::10}; done
When I try to put this inside a file (e.g. MyScript.sh) I run the following:
sh MyScript.sh
I receive the following error "MyScript.sh: 2: MyScript.sh: Bad substitution"
Why is this happening? How can this be fixed?