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.

Example

wc -l << EOF

> This is simple line

> this is also simple line

> EOF

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

Example

whoami > /dev/null

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



0 comments:

Post a Comment