User Tools

Site Tools


bash:redirection

This is an old revision of the document!


BASH - Redirection

Output Redirection

The '>' symbol is used for output (STDOUT) redirection.

ls -al > listings

Here the output of command ls -al is re-directed to file “listings” instead of your screen.

NOTE: Use the correct file name while redirecting command output to a file.

If there is an existing file with the same name, the redirected command will delete the contents of that file and then it may be overwritten.

If you do not want a file to be overwritten but want to add more content to an existing file, then you should use '»' operator.


Redirect standard output to devices

You can redirect standard output, to not just files, but also devices!

cat music.mp3 > /dev/audio

The cat command reads the file music.mp3 and sends the output to /dev/audio which is the audio device.

If the sound configurations in your PC are correct, this command will play the file music.mp3.


bash/redirection.1576351745.txt.gz · Last modified: 2020/07/15 10:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki