A safe way of declaring your string variables involves the usage of quotes. Think of it as a way of telling the function "here starts and over here ends my string". Although not necessary on this particular example, you can quote a phrase when using echo
as follows:
% echo 'this is a quoted phrase' > this is a quoted phrase
Single quotes are treated as delimiters by the shell and as such, they are completely ignored. The same rule applies to the print
built-in function:
% print 'this is a quoted phrase' > this is a quoted phrase
So, what's the point of using quotes then? Well, imagine for a moment that your output looks something like the following:
% echo this is a backslash: \ ~>
Yes, that will trigger a continuation line, so there's seemingly no way around it, save for using quotes. Let's try it again:
% echo 'this is a backslash: \' > this is a backslash: \
So, as a rule of thumb, we use single quotes when there are special characters on our string as...