Skip to main content
IBM 
ShopSupportDownloads
IBM HomeProductsConsultingIndustriesNewsAbout IBM
IBM : developerWorks : Linux : Education - Tutorials
LPI certification 101 exam prep, Part 2
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
5. Text processing
  


Whirlwind over! Redirection page 13 of 14


Similar to using > on the bash command line, you can also use < to redirect a file into a command. For many commands, you can simply specify the filename on the command line, however some commands work only from standard input.

Bash and other shells support the concept of a "herefile". This allows you to specify the input to a command in the lines following the command invocation, terminating it with a sentinel value. Here's an example:


$ sort <<END
apple
cranberry
banana
END
apple
banana
cranberry

In our example, we typed the words apple, cranberry, and banana, followed by "END" to signify the end of the input. The sort program then returned our words in alphabetical order.


Main menuSection menuFeedbackPreviousNext
PrivacyLegalContact