ADVERTISEMENT

Linux Commands ❯ cat

cat

Concatenate FILE(s), or standard input, to standard output.
syntax:

cat [OPTION]... [FILE]...
  • cat my_file1
    display the contents of my_file1
  • cat my_file1 my_file2
    display the contents of my_file1 and my_file2
  • cat > my_file1
    awaits input from user, type desired text and press CTRL+D (hold down Ctrl Key and type ā€˜dā€˜) to exit. The text will be written in my_file1 file.
  • cat my_file1 > my_file2
    redirects the contents of my_file1 to create my_file2. if my_file2 already exists, its contents will be over written.
  • cat my_file1 >> my_file3
    append the contents of my_file3 with my_file1. if my_file3 does not exist, a new file will be created with contents of my_file1
  • cat my_file1 my_file2 my_file3 > my_file4
    concatenate my_file1, my_file2, my_file3 and save as my_file4
  • cat < my_file1
    display the contents of my_file1
  • cat my_file1 | sort > my_file2
    sort the contents of my_file1 and create a new file my_file2 with that content
  • cat -b my_file1
    display the contents of my_file1 with each non-empty lines numbered
  • cat -E my_file1
    display the contents of my_file1 with $ at end of each line
  • cat -n my_file1
    display the contents of file my_file1 with the line numbers
  • cat -s my_file1
    display the contents of my_file1. multiple blank lines coming adjacent to each other will combined to a single blank line
  • cat -T my_file1
    display the contents of my_file1. the tabs are indicated by ^I