echo command in linux is used to display line of text/string that are passed as an argument . This is a built in command that is mostly used in shell scripts and batch files to output status text to the screen or a file.
echo [option] [string]
Displaying a text/string :
Options of echo command
NOTE :- -e here enables the interpretation of backslash escapes
1. \b : it removes all the spaces in between the text
echo -e "Geeks \bfor \bGeeks"
2. \c : suppress trailing new line with backspace interpretor ‘-e‘ to continue without emitting new line.
echo -e "Geeks \cfor Geeks"
In above example, text after \c is not printed and omitted trailing new line.
3. \n : this option creates new line from where it is used.
echo -e "Geeks \nfor \nGeeks"
4. \t : this option is used to create horizontal tab spaces.
echo -e "Geeks \tfor \tGeeks"
5. \r : carriage return with backspace interpretor ‘-e‘ to have specified carriage return in output.
echo -e "Geeks \rfor Geeks"
In the above example, text before \r is not printed.
6. \v : this option is used to create vertical tab spaces.
echo -e "Geeks \vfor \vGeeks
7. \a : alert return with backspace interpretor ‘-e‘ to have sound alert.
echo -e "\aGeeks for Geeks
This command when executed, it will produce an alert sound or Bel .
8. echo * : this command will print all files/folders, similar to ls command .
9. -n : this option is used to omit echoing trailing newline .
echo -n "Geeks for Geeks"
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.