Cat Command (Linux)

Useful References:

[1]  https://en.wikipedia.org/wiki/Cat_(Unix)

 

Tips:  Using the cat command in Linux.

[1] With no FILE, or when FILE is -, read standard input.

 

[2] Command line options I have found useful:

  • n (GNU only: –number), number all output lines

 

[3] To concatenate 2 text files and write them to a new file, you can use the following command:

$ cat file1.txt file2.txt > newcombinedfile.txt

With option -n, cat can also number lines as follows:

$ cat -n file1.txt file2.txt > newnumberedfile.txt

[4] To concatenate 2 files, while removing header from 2nd file this following cat command came to my rescue :

$ cat userCorpus_CMU_Featurized.csv <(tail -n +2 userCorpus_OKC_Featurized.csv) > output2.csv

  • Pro tip : For some weird reason, it would complain if there was a space between the < and (.  Not sure why.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s