Use cat to combine or print the contents of a file

December 26, 2009 โ€” Print the contents of a file:

cat filename.txt

Pipe the contents of the file to less, so you can view it one page at a time:

cat filename | less

In less, the 3 key commands are:

You can also do regular expression searches like in vim: /regex (n to go to next match)

Append file1 to the end of file 2:

cat file1 >> file2

Combine two files into a third file:

cat file1 file2 > file3

View source