This program can concatenate files, or standard input to standard output.
call cat [option] [file] ...
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonblank output lines
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank never more than one single blank line
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version output version information and exit
With no FILE, or when FILE is -, read standard input.
-B, --binary use binary writes to the console device.
We can use this plugin to concatenate files together and exploit the additional feature of showing the special characters in a file that are usually not visible by default.
We will demonstrate how the plugin can be used, by concatenating the second file right after the first file without giving any space between them. First, we will call the plugin with just one file name, which returns its contents to STDOUT.
We can then join these two files and display the joined file, using the cat command as shown below.
cat file1 file2
We can also save the concatenated result of two files in a third file, instead of displaying them in CMD. You don't have to create the third file. It will be created automatically, with the name you mention in CMD.
cat file1 file2 >> newfile
This plugin gives us the switch, -A, that will show all the special characters in a file that are usually hidden. As shown in the example below, it shows $ and ^M at the end of each line.we can also use either -E or -t for displaying these special characters. Likewise, -E is used to show $ at the end of the line, while -t is used to show ^M where a new line is used.
cat -A/-E/-t file
We can use this plugin to insert the line number in the relevant line of a file. To number the lines, we have two different types of switches.
This switch will number every line, whether it is blank or used.
cat -n file
This switch, unlike -n, will only number the lines with text, leaving the blank lines. Using this can be helpful when content is indented.
cat -b file