echo flags & options
Basic usage
Print text to stdout.
echo "Hello, world!"
-n
Don't output a trailing newline.
echo -n "Enter your name: "
-e
Enable interpretation of escape sequences.
echo -e "Line 1\nLine 2\nLine 3"
echo -e "Column1\tColumn2\tColumn3"
-E
Explicitly disable escape sequence interpretation (default behavior).
echo -E "No escapes: \n \t"
Common escape sequences
Newline, tab, backslash, and alert.
echo -e "Hello\nWorld"
echo -e "Name\tAge\tCity"
echo -e "Path: C:\\Users\\name"
Write to a file
echo "data" > file.txt
echo "more data" >> file.txt
Variable expansion
echo "Home directory: $HOME"
echo "Current shell: $SHELL"
Suppress with single quotes
Single quotes prevent variable expansion.
echo '$HOME is not expanded'