![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comparing PID values of 2 Files in shell Options | marconi | Shell Programming and Scripting | 2 | 12-19-2007 01:02 PM |
| Comparing two files.. | padarthy | Shell Programming and Scripting | 1 | 08-29-2007 09:01 AM |
| comparing shadow files with real files | terrym | UNIX for Advanced & Expert Users | 4 | 02-09-2007 02:38 AM |
| Script error.. for comparing 2 files! | gkrishnag | UNIX for Advanced & Expert Users | 4 | 09-13-2006 10:19 AM |
| shell script comparing files in a file | raina_nalin | Shell Programming and Scripting | 4 | 06-21-2005 07:00 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
shell script for comparing 2 files
Hi,
how to read the 2 files and compare each other in shell script? i have 2 files test1 and test2, both files contains 20 character records.we have to compare file 1 records with file2, if exists then reject the record else we have to append it to test2 file. in file test1 around 100 single column records are there. and test2 around 50000 single column records. how can we do in shell script? ex: test1 burningburning21sstt ex:test2 burningburning21eett we need to compare only first 16 letters of the record like if test1.burningburning21 = test2.burningburning21 then reject. Thanks in advance |
|
||||
|
Hi,
Try the below script. Customize, if required for line in `cat test1.lst|cut -c1-16` do grep -i $line test2.lst >/dev/null exitcode=$? if [ $exitcode = 0 ]; then echo "$line : String Exists" else echo "String does not exists, hence appending in test2 file" echo $line >> test2.lst fi done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|