The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
How to compare a field value of a same column? gobinath Shell Programming and Scripting 6 05-06-2009 01:39 AM
Compare 2 files for a single column and output differences samit_9999 UNIX for Dummies Questions & Answers 1 04-23-2008 12:02 PM
compare the column from 3 files and merge that line ganesh_mak Shell Programming and Scripting 8 04-14-2008 07:56 AM
awk compare column between 2 files phamp008 Shell Programming and Scripting 3 01-18-2008 12:24 AM
I need to extract last column of a file and compare the values vukkusila Shell Programming and Scripting 4 08-04-2007 11:21 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-29-2007
hanie123 hanie123 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 16
Compare Column value from Two Different Files

Hi, I need help to write a korn shell script to

1. Check and compare the first file contains single record from the /scp/inbox directory against the badpnt.dat file from the pnt/badfiles directory contains multiple records based on the fam_id column value start at position 38 to 47 from the record below. Here is an example of the record from the file in both directories:
PNT0220060503081122003700100000091049000005629001005146417001407712SFirstname Lastname
2. If fam_id is matched then move current file from the /scp/inbox directory into the pnt/badfiles directory.
If not then continue the normal process
This is what I have so far

pntcnt=`ls -l /$ROOTDIR/scp/inbox/badpnt | grep "PNT." | wc -l`
if [[ $pntcnt -gt 0 ]] then
ls /$ROOTDIR/scp/inbox/badpnt | grep "PNT." > /$ROOTDIR/scp/inbox/badpnt/pntprocess.dat
pntcnt=`wc -l /$ROOTDIR/scp/inbox/badpnt/pntprocess.dat|awk '{print $1}`
sleep 10
curcnt=1
while (( $curcnt <= $pntcnt ))
do
badpnt_chck=`head -$curcnt /$ROOTDIR/scp/inbox/badpnt/pntprocess.dat | tail -1`
fi

pntcnt1=`ls -l /$ROOTDIR/scp/inbox | grep "PNT." | wc -l`
if [[ $pntcnt1 -gt 0 ]] then
ls /$ROOTDIR/scp/inbox | grep "PNT." > /$ROOTDIR/scp/inbox/pntprocess.dat
pntcnt1=`wc -l /$ROOTDIR/scp/inbox/pntprocess.dat|awk '{print $1}`
sleep 10
curcnt1=1
do
inbox_chck=`head -$curcnt1 /$ROOTDIR/scp/inbox/pntprocess.dat | tail -1`
fi

Thank You

Last edited by hanie123; 03-29-2007 at 10:45 AM..
 

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 11:36 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