Bash - Standard input (stdin)

Bash Liste Des Attaques Ovh

About

Shell Data Processing - Standard Input Stream (Stdin) operations that applied only to the bash|bash shell

Creation

Manual

See Bash - Read (Builtin Command) that capture a line

File

The input redirection operator takes the content of a file and send it as standard input

Example with read that take a stand

read -p "Type Something: " myVar
echo "You answer was :" $myVar
read -p "Type still Something: " myVar
echo "Your second answer was :" $myVar
  • Create an input text file with two lines Hello and World
 echo $'Hello\nWorld' > myAnswer.txt
  • Give it to your script
./myScript.sh < myAnswer.txt
  • Output:
You answer was : Hello
Your second answer was : World

Inline string

The input redirection operator «< takes a string and send it as standard input

Example with read that take a stand

read -p "you name: " name <<< "Nico"
echo $name
  • Output:
Nico

Here document

Example for an Here document (a input document in the code) with tr and an output redirection.

tr a-z A-Z << END_TEXT > myText.file
 one two three
 four five six
 END_TEXT
ONE TWO THREE
FOUR FIVE SIX





Discover More
Bash Liste Des Attaques Ovh
Bash - Bash cli

Bash is an sh-compatible a shell that executes commands read: from the standard input or from a file (script). In addition to the single-character shell options documented in the description...
Bash Liste Des Attaques Ovh
Bash - Interactive Shell

An interactive shell is when bash is: started: without non-optionarguments without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)),...
Bash Liste Des Attaques Ovh
Bash - Read (Builtin Command) that capture a line

Read is a bash builtin command and read: by default one line or a number of characters (by option) from: the standard input, or from the file descriptor fd supplied as an argument to the...
Bash Liste Des Attaques Ovh
Bash - process

This article is the bash Process. To see how to manage another general linux process, see The process running the command is created. The process inherits the stdin, stdout, and stderr from...
Card Puncher Data Processing
Shell Data Processing - Cat command (short for concatenate)

cat generates a stream of data from one or more files It therefore concatenate files. Output file1.txt then file2.txt contents and redirect and create the file fileAll.txt Content of fileAll.txt...
Bash Liste Des Attaques Ovh
What are Redirections in Bash? Example and how-to

This article talks shell redirections in the Bash shell. Through redirection you can direct the input and output of a command to and from other files and programs, and chain commands together in a pipeline....



Share this page:
Follow us:
Task Runner