I have been told that the spaces are important in bash
or other shell scripts and I should not change the existence of spaces unless I know what I am doing. By "changing the existence" I mean either inserting a space between two non-space characters or removing a space between two non-space characters, e.g. changing var="$val"
to var ="$val"
or vice versa.
I want to ask
Are there any cases in which using a single space or using multiple consecutive spaces in a shell script makes a difference?.
(Of course, inserting/deleting a space in quotes makes a difference ,like changing from echo "a b"
to echo "a b"
or vice versa. I am looking for examples other than this trivial example.)
I have come across this question but that one is about adding and removing spaces between two non-space characters for which I know many examples that it would make a difference.
Any help would be appreciated. Include more varieties of shells if possible.