Javatpoint Logo
Javatpoint Logo

Linux Input Redirection

< stdin

The bash shell uses stdin to take input. In input redirection, a file is made input to the command and this redirection is done with the help of '<' sign.



Linux Input Redirection1

Look at the above snapshot, command "cat < file.txt" has taken 'file.txt' as input and displayed its content.

<< here document

The here document (sometimes also called here-is-document) is a way in which you can enter input until a certain sequence(usually EOF) is typed. The EOF (End Of File) can be typed or can be called by pressing (ctrl + d) keys.

Any word can be used in place of 'EOF' like we have used 'last'.



Linux Input Redirection2

Look at the above snapshot, in first example, 'file.txt' is ended when we typed 'EOF' and 'last' in second example.

<<< here string

The here string is used to directly pass strings to a command.


Linux Input Redirection3

Look at the above snapshot, in this example we have used base64 which we'll study later. Command "base64 <<< format.txt" has decoded file 'format.txt' and then by using command 'base64 -d' we got back our file 'format.txt'.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA