Special characters that can be used to manipulate
commands in the command line include
1.
Backslash (\)
2.
Greater than (>)
3.
Less than (<)
4.
Pipe (|)
5.
Ampersand (&)
Backslash:
Character prevents the shell from
treating another character as a special character through a process called
backslash escaping.
This allows us to split a command
statement across multiple lines. When we place the backslash at the end of a
line and then press Enter, we can continue the statement on the next line. The
backslash prevents the shell from treating the Enter keystroke – or new line
character – as a special character.
For Example:
$echo Long pieces of test may not
always fit onto to a single \
Line of the command
line interface, so it becomes \
Necessary to split
them across multiple lines using \
Backslashes.
Greater than (>):
Allows us to direct the standard output of a command to
a file or a device such as a printer instead of to the terminal screen.
For Eample:
$ ls –l /usr/home > userdirs
Less than (<):
Allows us to send the contents of a file to a command
as its standard output.
For Eg:
$ sort –d < list
Pipe line (|):
Direct the output of one command to the input of
another command.
For Example:
$ cat good | grep ‘India’
Ampersand(&):
Character at the end of a command statement allows us
to run commands in the background.
For Eg:
$ find / -name che &
[1] 48748
$ che
NOTE:
If we want to use special character in command line
text without the shell recognizing them as special characters, we have to
enclose them with a backslash (\).
For Example:
$echo Tours \& Accommodation
Tours & Accommodation
This eg shows an ‘echo’ command in which the ‘echo’
text contains an ampersand. There’s backslash
In front of the ampersand, which prevents the shell
from treating it as a special character.
No comments:
Post a Comment