In: Computer Science
Explain what each of the following metacharacters mean within the shell linux.
1. > (greater than)
2. < (less than)
3. | (vertical bar)
Metacharacters are special characters that are used to represent
something other than themselves .
Characters that are neither letters nor numbers may be metacharacters.
Shell metacharacters can be used to group commands together, to abbreviate filenames and pathnames, to redirect and pipe input/output, to place commands in the background, and so forth
1) > Redirection of output ls > file Redirects standard output to file.
2) < Redirection of input ls < file Redirects standard input from file.
3) | The Pipe (|)
==> Output Redirection (>)
The output from a command normally intended for standard output can be easily diverted to a file instead. This capability is known as output redirection.
If the notation > file is appended to any command that normally writes its output to standard output, the output of that command will be written to file instead of your terminal.
==> Input Redirection ( < )
The commands that normally take their input from the standard input can have their input redirected from a file in this manner.
Just as the output of a command can be redirected to a file, so can the input of a command be redirected from a file. As the
--> greater-than character > is used for output redirection,
--> less-than character < is used to redirect the input of a command.
The commands that normally take their input from the standard input can have their input redirected from a file in this manner.
==> | The Pipe (|)
Takes output from one program, or process, and sends it to another
The pipe ( | ) metacharacter sends that list to the grep command, which searches for any line in the list that contains f.. efox, where the periods refers to two of any character. If Firefox is running, you'll get a match. Similarly, if a program called fonefox or freefox is running, these are also returned
Pipe is used to combine two or more commands, and in this, the output of one command acts as input to another command, and this command’s output may act as input to the next command and so on. It can also be visualized as a temporary connection between two or more commands/ programs/ processes. The command line programs that do the further processing are referred to as filters.