The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-20-2008
senthil_is senthil_is is offline
Registered User
  
 

Join Date: Sep 2007
Location: singapore
Posts: 35
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.
  #2 (permalink)  
Old 02-20-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0