cat - Unix, Linux Command


Advertisements

Previous Page
Next Page  
 

NAME

cat - concatenate files and print on the standard output

SYNOPSIS

cat [OPTION]... [FILE]...

DESCRIPTION

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

OPTIONS

TAG DESCRIPTION
-A, --show-all equivalent to -vET
-b --number-nonblank

number nonempty output lines

-e equivalent to -vE
-E, --show-ends display $ at end of each line

 

 

-n, --number number all output lines

 

-s, --squeeze-blank suppress repeated empty output lines

 

-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

EXAMPLES

EXAMPLE-1:

To  Read the contents of a file  and display them on the screen.

$ cat system_1

output:

line 1
line 2
line 3

EXAMPLE-2:

To Copy standard input to standard output.

(With no FILE, or when FILE is -, read standard input)

$ cat         or
$ cat -

output:

hello <standard input>
hello <standard output>
print
print

EXAMPLE-3:

To create and write content to a file 'xyz'.

$ cat > xyz

output:
line 1
line 2
line 3
line 4
^C Note: to exit press ctr^c.

~$ cat xyz
line 1
line 2
line 3
line 4

EXAMPLE-4:

 To append content to a file 'xyz'.

$ cat >> xyz

output:
line 6
line 6
Note: to exit press ctr^c.

cat xyz
line 1
line 2
line 3
line 4
line 6
line 6

EXAMPLE-5:

To print all content to a file 'xyz'.

$ cat -A xyz

output:

line 1$
line 2$
line 3$
line 4$
line 6$
line 6$

EXAMPLE-6:

To show ends of line of file 'xyz'.

$ cat -E xyz
Note: shows $ at the end of each line.

output:

line 1$
line 2$
line 3$
line 4$
line 6$
$ine 6$

EXAMPLE-7:

To number all lines of file 'xyz'.

$ cat -n xyz

output:

1 line 1
2 line 2
3 line 3
4 line 4
5 line 6
6 line 6

 

EXAMPLE-8:

To number nonempty lines of file 'xyz'.

$ cat -b xyz

output:
1 line 1
2 line 2
3 line 3
4 line 4
5 line 6
6 line 6

EXAMPLE-9:

 To show TABS of file 'xyz'.

$ cat -T xyz
Note: displays TAB characters as ^I.

output:

line 1
line 2
line 3
line 4
line 6
line 6


Previous Page
Next Page