cat

Command for various file operations:

  • Viewing file content
  • Combining multiple files
  • Using useful options:
    • -n: to show line numbers
    • -E: to highlight end-of-line ( this will show $ in the end of line)
    • -A: to show all non printed characters (equivalent to -vET)
    • -b: to number non-blank output lines
    • -s: to suppress repeated empty output lines
    • -T: to display TAB characters as ^|
    • -v: Use ^ and M- notation, except for LFD and TAB

Syntax of cat command

cat [options] filename

Create a new file and add content

cat > filename
  • type content
  • press ctrl+D to save and exit

Copy or merge file contens

cat file1 file2 > merged_file

Open files whose names start with dash (-)

cat -- filename

example:

cat -- -list.txt