Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » CommandsRSS Feeds

Concatenate, copy, print files - cat

Posted By: Ben Evans     Category: Unix / Linux / Ubuntu     Views: 7639

This article explains about cat command with an example in unix.

cat command is used to concatenate, copy, print files in unix.

• Cat reads each file in a sequence and writes it on the standard output.
• Thus cat file prints file on the default standard output device.

Syntax of cat Command

cat [-options] fileName

Most Commonly used options are:
  • -e $ is printed at the end of each line. This option must be used with -v.
  • -s Suppress messages pertaining to files that do not exist.
  • -t Each tab will display as ^I and each form feed will display as ^L. This option must be used with -v.
  • -u Output is printed as unbuffered.
  • -v Display control characters and nonprinting characters.

Example of cat Command

cat file1 file2 > file3

Above example concatenates file1 and file2, and place the result in the file3.

Didn't find what you were looking for? Find more on Concatenate, copy, print files - cat Or get search suggestion and latest updates.

Ben Evans
Ben Evans author of Concatenate, copy, print files - cat is from London, United Kingdom.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

Balaji Kannan from India Comment on: Jul 28
I need the following programs in Linux.

1. Accept a file name, starting and ending line numbers as arguments and display all the lines between the given line number.

2. Delete all lines containing a specified word in one or more files supplied as arguments to it.

3.Receive any number of file names as its arguments, check if every argument supplied is a file or a directory and reports accordingly.
whenever the argument is a file, the number of lines on it is also reported.

4. Receive any number of file names as its arguments, counts and reports the occurrence of each word that is present in the first argument file on other argument file.

5. Display a list of all files in the current directory to which the user has read, write and execute permissions.

View All Comments