Where to start First steps track · 15 stages
Linux Labs

echo — printing text

cheat sheet · bash https://lab.dimsanych.ru/en/wiki/echo/

Cheat sheet

  • echo "x=$var" with variable expansion
  • echo 'literal $x' without expansion
  • echo -n / echo -e no trailing \n / with escapes
  • echo "x" >> file append to a file
  • printf '%s\n' "$v" a portable equivalent

Options

bash
echo -n "no trailing newline"   # -n: don't append \n at the end
echo -e "column1\tcolumn2"      # -e: enable escapes (\t \n \\)
echo "stars: *"                # inside quotes, * is NOT expanded into filenames
echo *                          # WITHOUT quotes — a list of files (globbing!)

Rule of thumb: variables and special characters go in double quotes; fully literal text goes in single quotes. More on expansion — globbing and env-vars.

Loading…