ADVERTISEMENT

Linux Commands ❯ echo

echo

display a line of text
syntax:

echo [OPTION]... [STRING]...
  • echo this is a text
    display - this is a text - with a trailing new line.
  • echo "this is a text"
    display - this is a text - with a trailing new line.
  • echo "my sentence"
    display - my sentence( will not interpret escape characters inside the quotes on default.)
  • echo *
    list all the files and directories in the current directory
  • echo *.txt
    list all the files and directories with an txt extension in the current directory
  • echo */
    list ONLY the directories in the current directory
  • echo $PWD
    display the current working directory
  • echo $PATH
    display the currently defined PATH
  • echo ~
    display the home directory
  • echo "this is a text" > my_file1
    create my_file1 with content "this is a text". if my_file1 already exists, its contents will be overwritten.
  • echo "this is a text" >> my_file1
    append the contents of my_file1 with "this is a text". if my_file1 does not exist, a new file will be created with the same text.
  • echo `date`
    execute date command and display the output.
  • echo -E "my sentence"
    display - my sentence.( will not interpret escape characters inside the quotes.)
  • echo -e "my sentence"
    display - my sentence( will interpret escape characters inside the quotes, in this case a TAB .)
  • echo -e "\"
    display \
  • echo -e "a"
    alert(BEL)
  • echo -e "\b"
    display backspace
  • echo -e "\n"
    display new line
  • echo -e " "
    display carriage return(enter)
  • echo -e "\t"
    display TAB
  • echo -n this is a text
    display - this is a text - with OUT a trailing new line.