feed-image  Delivered by FeedBurner  ISSN 1836-5930





Poll

Which of following tutorials would you like to see on the Linuxconfig.org?
 
Partner Linux Sites
TuxMachines
DebianAdmin
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
FreeSoftwareLinux
Jam's Ubuntu Blog
All For Linux

cat
Article Index
1. Name
2. Synopsis
3. Frequently used options
4. Examples

1. Name

cat [man page] - concatenate files and print on the standard output

2. Synopsis

cat [OPTION] [FILE]... 

3. Frequently used options

-n, --number        number all output lines 

4. Examples

cat read content of a file(s) and print then on standard output which is in many cases our terminal. Lets suppose that our file samba.txt contain text:
Samba file and printer sharing is supported by all Linux Distributions: Suse Linux, Debian Linux,
Mandrake Linux, Red Hat Linux, Fedora Linux, Gentoo Linux
When we cat file cat.txt cat will read content of a file a spit it out to stdout:
cat samba.txt 
cat will read content of a file
As a description of this command suggest we can also concatenate two files. Our second file ubuntu.txt contain:
and Ubuntu Linux. 
Lets see what happens when we cat both files at once:
$ cat samba.txt ubuntu.txt 
cat both files at once
Now we can use cat to concatenate two files and create new file samba_support.txt.
$ cat samba.txt ubuntu.txt > samba_support.txt 
concatenate two files with cat command
With use of pipe we can redirect output of cat command to another command such us bc:
$ echo '2+2' > '2+2.txt' $ cat 2+2.txt | bc 
redirect output of cat command
by -n option we also tell cat to number lines:
$ cat -n samba_support.txt 
cat can number lines