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
compare 2 files.. amon Shell Programming and Scripting 8 06-23-2008 10:34 AM
compare two files charandevu Shell Programming and Scripting 7 03-30-2008 03:20 PM
Compare files kharen11 UNIX for Advanced & Expert Users 25 03-14-2007 05:35 AM
compare files and beyond MizzGail UNIX for Dummies Questions & Answers 2 04-25-2003 01:34 PM
compare files ingunix UNIX for Dummies Questions & Answers 3 05-24-2001 11:44 AM

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

Join Date: Mar 2007
Posts: 2
Cool compare files

Hi,

I need to compare files in 2 recursive directories.
I need to create a script which:
1. Unzip files recursive.
2. Check if all the files in one directory exist in the other, if not
print out the file name.
3. Check if the content of the files are the same,
if not the file name and different content will be displayed in a different file.

Thanks
  #2 (permalink)  
Old 03-20-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
The list you had provided, just seems like a

WHAT TO DO instructions !

But what have you tried so far !
  #3 (permalink)  
Old 03-21-2007
danabo danabo is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 2
gunzip -fr *

# Check if there are diff file between the directories

ls -l bb_R4 | grep ^d |awk '{print }' |tee a| ls -l bb_Core | grep ^d |awk '{print }' |tee b|diff a b

dircmp -ds bb_R4 bb_Core
  #4 (permalink)  
Old 05-19-2008
newinawk newinawk is offline
Registered User
  
 

Join Date: May 2008
Posts: 6
Compare 2 files with multiple fields

Hi,

Not sure if this is the right place.
I'm having some trouble with a script.
Basically I have 2 files, the first has the following format:

59382652678,59382652678,093582673
59382828082,59382828082,091531434
59382965276,59382965276,097447775
59385125137,59385125137,085430172
59385184928,59385184928,094012044

And the second file is much larger ($HOME/20080410_10*)
20537,59393495882,2008-04-10,35727,50,1,740010104911699, ,2,-14000,088807321,40553,0,0,9,0,0,088807321,,XXXX 1-7-9,0,0,0,0,-1,740011018811772,XXXXXX,,0,0,14000,0,0,XXXXXX,0,401D413D0E01DD,,,10,59397995026,59397995026,,0,0,0, 0,0,0,0,0,0,0,0,1,XXXX,50,61,0,9999,1,71340044,0,0,50,-1,0,1970-01-01

The second and third field of the first file corresponds to the 2nd and 18th field of the second file.

I have worked on the script but I can only compare one field between the files

for i in `ls $HOME/20080410_10*`
do
nawk -F, 'BEGIN {while ((getline < "'$file2'") > 0)
file2_ar[$2] = $2; <<<< This is the second field, how do I assing the third filed???
OFS=","; }

{
if (file2_ar[$2] && $9==2)
print file2_ar[$2],$0;
} END{}' $i >> output.log
done


Does anyone have an idea on how it can be solved?

Thanks,

Last edited by newinawk; 05-19-2008 at 02:19 PM.. Reason: Opened new thread with issue
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 06:01 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