Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cat(1) [bsd man page]

CAT(1)							      General Commands Manual							    CAT(1)

cat - catenate and print SYNOPSIS
cat [ -u ] [ -n ] [ -s ] [ -v ] file ... DESCRIPTION
Cat reads each file in sequence and displays it on the standard output. Thus cat file displays the file on the standard output, and cat file1 file2 >file3 concatenates the first two files and places the result on the third. If no input file is given, or if the argument `-' is encountered, cat reads from the standard input file. Output is buffered in the block size recommended by stat(2) unless the standard output is a terminal, when it is line buffered. The -u option makes the output completely unbuffered. The -n option displays the output lines preceded by lines numbers, numbered sequentially from 1. Specifying the -b option with the -n option omits the line numbers from blank lines. The -s option crushes out multiple adjacent empty lines so that the output is displayed single spaced. The -v option displays non-printing characters so that they are visible. Control characters print like ^X for control-x; the delete char- acter (octal 0177) prints as ^?. Non-ascii characters (with the high bit set) are printed as M- (for meta) followed by the character of the low 7 bits. A -e option may be given with the -v option, which displays a `$' character at the end of each line. Specifying the -t option with the -v option displays tab characters as ^I. SEE ALSO
cp(1), ex(1), more(1), pr(1), tail(1) BUGS
Beware of `cat a b >a' and `cat a b >b', which destroy the input files before reading them. 4th Berkeley Distribution May 5, 1986 CAT(1)

Check Out this Related Man Page

cat(1)							      General Commands Manual							    cat(1)

       cat - concatenate and print data

       cat [ -b ] [ -e ] [ -n ] [ -s ] [ -t ] [ -u ] [ -v ] file...

       The  command reads each file in sequence and displays it on the standard output.  Therefore, to display the file on the standard output you
       cat file
       To concatenate two files and place the result on the third you type:
       cat file1 file2 > file3
       To concatenate two files and append them to a third you type:
       cat file1 file2 >> file3
       If no input file is given, or if a minus sign (-) is encountered as an argument, reads from the standard input file.  Output is buffered in
       1024-byte blocks unless the standard output is a terminal, in which case it is line buffered.  The utility supports the processing of 8-bit

       -b   Ignores blank lines and precedes each output line with its line number.

       -e   Displays a dollar sign ($) at the end of each output line.

       -n   Precedes all output lines (including blank lines) with line numbers.

       -s   Squeezes adjacent blank lines from output and single spaces output.

       -t   Displays non-printing characters (including tabs) in output.  In addition to those representations used with the -v  option,  all  tab
	    characters are displayed as ^I.

       -u   Unbuffers output.

       -v   Displays  non-printing  characters (excluding tabs and newline) as the ^x.	If the character is in the range octal 0177 to octal 0241,
	    it is displayed as M-x. The delete character (octal 0177) displays as ^?.  For example, is displayed as ^X.

See Also
       cp(1), ex(1), more(1), pr(1), tail(1)

Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Redirect output to a file

Ahhhrrrggg I'm having a brain fart... I want to take the output of a command and redirect it to a file... This works.... $ man cp | cat >> copy_help but this doesn't keytool -help |cat >> keytool_help It just produces... these lines... more keytool_help ] ... ... (11 Replies)
Discussion started by: jimmyc
11 Replies

2. UNIX for Dummies Questions & Answers

cat binary file -> terminal gibberish

I've used *nix systems for some time now and have frequently seen a terminal turn to gibberish after using cat or more on a binary file. I'm sure many others have also noticed this. Normally, I just exit the terminal, but I would like a better solution. Certainly there is some way to "reset" a... (11 Replies)
Discussion started by: quantumechanix
11 Replies

3. Shell Programming and Scripting

help using read in menu script to cat out lines in logs

What is wrong with my menu script? Do I need to continue with the read statements? All I want to do with option 4 is to cat some /var/log/files and awk out a few lines? How do I do that please? $ cat ... (11 Replies)
Discussion started by: taekwondo
11 Replies

4. What is on Your Mind?

Help me name a fictional cat

Hi people I'm writing a short story and there is a cat in it. The cat belongs to a hacker, so I need a name for it that would make a Unix/Linux person chuckle. I don't know much at all about Unix or Linux, or indeed hacking, and was going to call the cat Torvalds, or Root. Both good names for... (17 Replies)
Discussion started by: mazzz_in_Leeds
17 Replies

5. Shell Programming and Scripting

Unix help to find blank lines in a file and print numbers on that line

Hi, I would like to know how to solve one of my problems using expert unix commands. I have a file with occasional blank lines; for example; dertu frthu fghtu frtty frtgy frgtui frgtu ghrye frhutp frjuf I need to edit the file so that the file looks like this; (10 Replies)
Discussion started by: Lucky Ali
10 Replies

6. Shell Programming and Scripting

cat and output filename

Hi, how I can display a file with cat and printing the filename before each line. e.g. file1 { one two three four five } Output: file1:one file2:two file1:three file1:four file1:five (12 Replies)
Discussion started by: Timmää
12 Replies

7. Shell Programming and Scripting

Cat Command and Blank Lines

Hi All, I was testing for blank lines and I want to use the cat command only for groupline in `cat /home/test/group` do if then echo "blank found" fi done I want to check if the current line read is a blank line. I have tested with $groupline="\n" ,... (11 Replies)
Discussion started by: datkan
11 Replies

8. Shell Programming and Scripting

Cat piped output

Hello, How can I efficiently cat piped output with another file? > (awk command) | cat file1 (piped output) Thanks! (11 Replies)
Discussion started by: palex
11 Replies

9. Shell Programming and Scripting

Compare multiple files and print unique lines

Hi friends, I have multiple files. For now, let's say I have two of the following style cat 1.txt cat 2.txt output.txt Please note that my files are not sorted and in the output file I need another extra column that says the file from which it is coming. I have more than 100... (19 Replies)
Discussion started by: jacobs.smith
19 Replies

10. UNIX for Dummies Questions & Answers

Removing blank lines not working

In my bash script I want to echo lines in a file and ensure no blank lines are echoed:for i in $(cat txt) do echo $i | sed 's/|/ /g;s/ SEARCHTERM$//g;s/ /\r\n/g;s/^$/d' done Keep in mind this is a fragment so ignore the fact that the for loop is not closed. When I add the "s/^$/d' per... (12 Replies)
Discussion started by: MaindotC
12 Replies

11. Shell Programming and Scripting

String concatenation

Hi, I have two files. cat file.txt a b c d cat file1.txt j k l m I need the output as a:j (12 Replies)
Discussion started by: nareshkumar522
12 Replies

12. Shell Programming and Scripting

Output all data of files into one file

I have three files (can be more than 3): cat Katty => d4r4ff5rf5 =>cat Manu ffrs44frfrf =>cat Chris derfe5rgrg So basically, these files are in /Users/Unknown/files/*. Files can be... (11 Replies)
Discussion started by: Manu1234567
11 Replies

13. UNIX for Dummies Questions & Answers

BCP with cat not working

Hello, I am facing a typical problem in my code . If I run bcp alone it is working fine if I run BCP with cat it is not working . Not able to find where the error is occurring in cat . Can you please help bcp ${_DBName}..logfile in ${_currdate} -f$PANEL_HOME/format/logfile.fmt -Q -U$_UserId... (11 Replies)
Discussion started by: arunkumar_mca
11 Replies

14. Shell Programming and Scripting

Get the average of lines with the same first 4 letters

How to sum up and print into the next line the total SUM. ]$ cat hhhh aaa1a 1 aaa1g 2 aaa1f 3 baa4f 3 baa4d 4 baa4s 4 cddg1 3 cddg3 4 cddfg 1 $ cat hhhh|awk ' {sum+=$2} END {print sum}' 25 Desire output: aaa1a 1 (13 Replies)
Discussion started by: kenshinhimura
13 Replies

15. UNIX for Beginners Questions & Answers

How to print 1 file then when finished another file prints beside it?

I have 2 big files over 4Gbs each. I'm looking for a way to print 1 file, then when that file finish printing another file proceeds to print beside it and merge the lines together. How would to cmd or code this? from itertools import izip_longest with open("file1") as textfile1,... (14 Replies)
Discussion started by: bigvito19
14 Replies