Use cat to combine or print the contents of a file
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:
- spacebar to go forward one page
- b to go back one page
- q to quit
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
Posted 01/26/2010
blog comments powered by Disqus