UnixDroid

Shell · Linux command

echo command in Linux

What does echo do?

echo prints text or the value of variables. With > or >> it writes text into files.

echo [-n] [-e] text

Most useful options

OptionWhat it does
-nno newline at the end
-eunderstand \n and \t

echo examples

$ echo Hello Try it ›

print text

$ echo $HOME Try it ›

print a variable

$ echo "line" >> file.txt Try it ›

add a line to a file

In security work

echo "text" | base64 -d decodes data quickly in CTFs.

Questions about echo

How do I write to a file from the terminal?

echo "text" > file replaces it; echo "text" >> file adds to the end.