[gllug] echo

Robert Newson ran at bullet3.fsnet.co.uk
Wed Apr 20 18:56:30 UTC 2005


Steve Nelson wrote:

> Richard wrote:
> 
>>The point is that what you type isn't what gets sent to echo.  The
>>shell performs expansion *before* passing the command-line onto the
>>command....
> 
> Ah yes, of course.
> 
> Hence why it must be escaped or quoted.  Speaking of which, am I
> correct in remembering that if one quotes with " ", $ ' and \ retain
> their meaning, whereas all characters inside a pair of single quotes
> are assumed to have their literal value?

Single quotes (') are used to quote a whole string to be literal - and it 
appears as a single argument.

Double quotes (") are used to quote a string (or variable expansion, etc) 
that could be split up into multiple args (due to the presence of IFS chars) 
and ensure that it isn't.

(eg if $FILE contains a filename with spaces in it, then "$FILE" ensures 
that FILE is expanded to the filename, but that the spaces are NOT treated 
as argument spearators, ieeg if FILE is "My Documents", then $FILE would 
generate 2 arguments: "My" and "Documents", whereas "$FILE" would generate 1 
argument: "My Documents" (assuming default IFS).)

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list