Skip to Content
Learning Linux Shell Scripting - Second Edition
book

Learning Linux Shell Scripting - Second Edition

by Ganesh Sanjiv Naik
May 2018
Beginner
332 pages
7h 28m
English
Packt Publishing
Content preview from Learning Linux Shell Scripting - Second Edition

Redirection

When a file descriptor is assigned to something other than a terminal, this is called I/O redirection. The shell performs the redirection of output to a file by closing the standard output file descriptor 1 (the Terminal) and then assigning that descriptor to the file. When redirecting standard input, the shell closes file descriptor 0 (the Terminal) and assigns that descriptor to a file. The Bash shells handle errors by assigning a file to file descriptor 2.The following command will take input from the sample.txt file:

    $ wc  <  sample.txt  

The preceding command will take content from the sample.text file. The wc command will print the number of lines, words, and characters in the sample.txt file. This command will redirect output ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting

Learning Linux Shell Scripting

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788993197Supplemental Content