Thursday, April 7, 2022

Linux - IO Redirection

 Output Redirection(>,>>)

It represents the output of a command to some standard output.

who > users

cat users

date >> users # append date in users file

cat user

Input Redirection(<)

It redirects the input of a command to a file.

cat filename

cat< filename

Here document(<<)

It is used to redirect input into an interactive shell or program.


wc -l << EOF

> This is simple line

> this is also simple line


Discard Output

Sometimes you need to execute the command but you don't want to output displayed on the screen then in such cases you can discard the output by redirecting it to /dev/null


whoami > /dev/null

null is a special type of file which discards the input as soon as it recieves.


Post a Comment