![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| compare the column from 3 files and merge that line | ganesh_mak | Shell Programming and Scripting | 8 | 04-14-2008 04:56 AM |
| awk compare column between 2 files | phamp008 | Shell Programming and Scripting | 3 | 01-17-2008 09:24 PM |
| compare two col from 2 files, and output uniq from file 1 | pp56825 | Shell Programming and Scripting | 2 | 01-10-2008 08:10 AM |
| Compare Column value from Two Different Files | hanie123 | Shell Programming and Scripting | 7 | 04-02-2007 06:34 AM |
| compare 2 files, output dups to file | blt123 | UNIX for Dummies Questions & Answers | 2 | 07-15-2004 07:31 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Compare 2 files for a single column and output differences
Hi,
I have a column in 2 different files which i want to compare, and output the results to a different file. The columns are in different positions in those 2 files. File 1 the column is in position 10-15 File 2 the column is in position 15-20 Please advise Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
With "the results", do you mean whether they were identical, or which lines differed, or which lines were identical, or both, or something else?
The comm command can compare sorted files. If your shell supports the <(...) construction, you don't even need temporary files: Code:
comm <(cut -c10-15 file1 | sort) <(cut -c15-20 file2 | sort) >results Code:
cut -c10-15 file1 | sort >/tmp/file1.tmp cut -c15-20 file2 | sort >/tmp/file2.tmp comm /tmp/file1.tmp /tmp/file2.tmp >results resultcode=$? # in case you want it rm /tmp/file1.tmp /tmp/file2.tmp |
|||
| Google The UNIX and Linux Forums |