0% found this document useful (0 votes)
16 views

1.7 Prompting: / Is Convenient For Quoting Single Characters. When More Than One Character Needs Quoting The

The document discusses different quoting mechanisms in shells, including using single quotes to quote a string of characters while preserving newlines, and double quotes to prevent interpretation of some but not all special characters. It also covers shell prompts that can be customized using variables like PS1 and PS2, and how the shell is called at login to read and execute commands from the user's .profile file.

Uploaded by

arunabhatla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

1.7 Prompting: / Is Convenient For Quoting Single Characters. When More Than One Character Needs Quoting The

The document discusses different quoting mechanisms in shells, including using single quotes to quote a string of characters while preserving newlines, and double quotes to prevent interpretation of some but not all special characters. It also covers shell prompts that can be customized using variables like PS1 and PS2, and how the shell is called at login to read and execute commands from the user's .profile file.

Uploaded by

arunabhatla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

\ is convenient for quoting single characters.

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.8 The shell and login


Following login (1) the shell is called to read and execute commands typed at the terminal. If the user's login directory contains the file .profile then it is assumed to contain commands and is read by the shell before reading any commands from the terminal.

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.

2.0 Shell procedures


The shell may be used to read and execute commands contained in a file. For example,
sh file [ args ... ]

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

You might also like