![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem in string comparision | ganapati | UNIX for Dummies Questions & Answers | 1 | 01-29-2008 10:08 AM |
| String comparision in shell scripting | Anji | Shell Programming and Scripting | 2 | 01-15-2008 06:07 AM |
| while - comparision | sharif | Shell Programming and Scripting | 2 | 11-01-2007 05:58 AM |
| Extracting a string from one file and searching the same string in other files | mohancrr | Shell Programming and Scripting | 1 | 09-19-2007 04:17 AM |
| date comparision | kotasateesh | UNIX for Dummies Questions & Answers | 3 | 07-20-2007 12:25 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
comparision of string in various files
i want to take position 19-24(only first line) from all files and need to compare any duplication is there or not.
If duplication, then i have to print the file names. I have written to take the characters from 19-24 from all files. but how to compare ? fPath='/lacbibs/out/files/prod_fixes' for in_filename in `ls -rt $fPath/*CTR*` do slBankId=`head -1 $in_filename| cut -c 19-24` echo "$in_filename : $slBankId " done Output of the above script is : /lacbibs/out/files/prod_fixes/P.207.20080221.dat : 103415 /lacbibs/out/files/prod_fixes/P.208.20080221.dat : 103420 /lacbibs/out/files/prod_fixes/P.209.20080221.dat : 103424 /lacbibs/out/files/prod_fixes/P.210.20080221.dat : 103415 /lacbibs/out/files/prod_fixes/P.211.20080221.dat : 103432 /lacbibs/out/files/prod_fixes/P.212.20080221.dat : 103436 /lacbibs/out/files/prod_fixes/P.213.20080221.dat : 103441 The below two files are having same string. i want to display these two filenames. /lacbibs/out/files/prod_fixes/P.207.20080221.dat /lacbibs/out/files/prod_fixes/P.210.20080221.dat can anyone help on this. Thanks in advance. |
|
||||
|
Redirect the output of "echo" in your for loop to a file called "outfile" and append following code to your code.
while read one_line do field=`echo "$one_line" | cut -d: -f2 | cut -c2-` if [ `grep -c $field outfile` -gt 1 ] then echo "$one_line" | cut -d" " -f1 fi done < outfile |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|