sh Output Handling

Writing to screen

echo Hello World

echo "Hello World"

printf "Hello World\n"

Writing to a file

Command

echo hello >output.txt

exho hello >output.txt

echo hello 2>output.txt

exho hello 2>output.txt

echo hello >output.txt 2>&1

exho hello >output.txt 2>&1

echo hello | tee output.txt

exho hello | tee output.txt

echo hello 2>&1 | tee output.txt

exho hello 2>&1 | tee output.txt

Screen

 

ksh: exho:  not found.

hello




hello

ksh: exho:  not found.

hello

ksh: exho:  not found.

output.txt

hello 

 


ksh: exho:  not found.

hello

ksh: exho:  not found.

hello


hello

ksh: exho:  not found.

Appending to a file

Command

echo hello >output.txt

Screen

 

output.txt

hello

echo hello >>output.txt

    

hello

hello

echo hello | tee -a output.txt

hello

hello

hello

hello

exho hello | tee -a output.txt

ksh: exho:  not found.

hello

hello

hello

exho hello 2>&1 | tee -a output.txt

ksh: exho:  not found.

hello

hello

hello

ksh: exho:  not found.

Bibliography