Lesser known linux commands: comm

November 29, 2009

comm compares two sorted files and produces three column output. First column contains lines only in first file,second column contains lines only in second file and third column contains common line.

Let me explain with an example.

$ cat f1

line 1

line 2

line 3

line 4

line 5

$ cat f2

line 1

line 2

line 2a

line 3a

line 4

line 5

$ comm f1 f2

line 1

line 2

line 2a

line 3

line 3a

line 4

line 5

comm has options like

-1 suppress first column -2 suppress second column -3 suppress 3rd column.

You can combine them also. e.g if you want only common lines use -12.

Where is it useful? Once, two persons have modified spreadsheet copied out of same source. I wanted to extract unique rows from each and insert into original. It is tedious to compare the changes visually. I dumped them into csv, sorted and ran comm to examine and merge with originial.


Monsoon Morning Visitors

November 13, 2009

This year suburban Chennai experienced one of the worst drought years. Chitlapakkam is where wells never go dry. But this year they went and almost every house drilled the earth upto 150 feet in search of water. Many failed. The fact is – water is available between 20 – 40 feet only. No point in drilling beyond, especially if you are struck in a rock. The problem aggravated by 15 days delayed monsoon. But once it arrived, the 4 days of rain was copious and brought welcome change. All the plants glow now. Last Sunday morning it was bright sunshine playing hide and seek with clouds.

The weather triggered a flurry of activity among fauna in my street. Here are some of the Sunday morning visitors

00075

00071

00063

000550004900040000380003400001


அதிகம் அறியாத லினக்ஸ் ஆணைகள்

November 3, 2009

நான் எழுதும் Little  known linux commands ன் தமிழாக்கம்  தமிழ் பக்கங்களில் தொகுத்து வருகிறேன். இன்று strings சேர்த்துள்ளேன்.

இங்கே சொடுக்கவும்


Follow

Get every new post delivered to your Inbox.

Join 40 other followers