1.7 Prompting: / Is Convenient For Quoting Single Characters. When More Than One Character Needs Quoting The
1.7 Prompting: / Is Convenient For Quoting Single Characters. When More Than One Character Needs Quoting The
When more than one character needs quoting the above mechanism is clumsy and error prone. A string of characters may be quoted by enclosing the string between single quotes. For example,
echo xx'****'xx
will echo
xx****xx
The quoted string may not contain a single quote but may contain newlines, which are preserved. This quoting mechanism is the most simple and is recommended for casual use.
A third quoting mechanism using double quotes is also available that prevents interpretation of some but not all metacharacters. Discussion of the details is deferred to section 3.4.
1.7 Prompting
When the shell is used from a terminal it will issue a prompt before reading a command. By default this prompt is `$ '. It may be changed by saying, for example,
PS1=yesdear
that sets the prompt to be the string yesdear. If a newline is typed and further input is needed then the shell will issue the prompt `> '. Sometimes this can be caused by mistyping a quote mark. If it is unexpected then an interrupt (DEL) will return the shell to read another command. This prompt may be changed by saying, for example,
PS2=more
1.9 Summary
ls Print the names of files in the current directory. ls >file Put the output from ls into file. ls | wc -l Print the number of files in the current directory.
ls | grep old Print those file names containing the string old. ls | grep old | wc -l Print the number of files whose name contains the string old. cc pgm.c & Run cc in the background.
calls the shell to read commands from file. Such a file is called a command procedure or shell procedure. Arguments may be supplied with the call and are referred to in file using the positional parameters $1, $2, .... For example, if the file wg contains