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
how to write script in tar naveeng.81 Shell Programming and Scripting 1 04-18-2008 01:04 PM
Please write this script for me nadman123 Shell Programming and Scripting 1 04-08-2008 11:30 PM
How to write script for this ? me_haroon AIX 0 07-01-2006 07:30 AM
need help to write shell script getdpg Shell Programming and Scripting 0 04-10-2006 11:30 AM
Help! Need to write my first script fundidor Shell Programming and Scripting 5 01-08-2004 10:20 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 09-30-2007
gyana_cboy gyana_cboy is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 9
Help me to write the script

Actually i am working with two diffrent files having same structure
each file contain Ten diffrent column and i want to write a script
which will compare the colummns of first file with the column of second file and diiference will be send to the first column of third file .

similarly for other columns ......
the third file is having the same structure as the previous two files..
  #2 (permalink)  
Old 10-01-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,429
Please give us an example.
  #3 (permalink)  
Old 10-01-2007
gyana_cboy gyana_cboy is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 9
Can you get me the script of comparing data in two sheets.

Say for eg

column A,,,,,, for sheet 1

column B,,,,,, for sheet 2



I want all the columns of sheet 1 should be compared with sheet 2 (both the sheet are having same columns & structure)



Wherever data is mismatching it should give me the details in any 3rd sheet .
  #4 (permalink)  
Old 10-01-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,429
Please give us a full example.
Input files with many rows, and expected output file.
  #5 (permalink)  
Old 10-04-2007
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,089
awk

HI,
To be honest, you did not give out the detail requirements. Suppose it is as follow (remember give example if possible).

input:


Code:
a:
a b c d e f g
b c d e f g h
c d e f g h i
2 b 4 d 5 f 7
b:
b c d e f g h
g d e f g h i
k e f g h i j

output:

Code:
    a     e     c
    c           4
    2           f
    g
    k

code:

Code:
cat a b >c
nawk '{
if (a=="")
        a=sprintf("%s",$1)
else
{
        if (index(a,$1)==0)
                a=sprintf("%s,%s",a,$1)
        else
        {
                a=sprintf("%s%s",substr(a,1,index(a,$1)-1),substr(a,index(a,$1)+2,length(a)-index(a,$1)-1))
        }
}
if (b=="")
        b=sprintf("%s",$2)
else
{
        if (index(b,$2)==0)
                b=sprintf("%s,%s",b,$2)
        else
                b=sprintf("%s%s",substr(b,1,index(b,$2)-1),substr(b,index(b,$2)+2,length(b)-index(b,$2)-1))
}
if (c=="")
        c=sprintf("%s",$3)
else
{
        if (index(c,$3)==0)
                c=sprintf("%s,%s",c,$3)
        else
                c=sprintf("%s%s",substr(c,1,index(c,$3)-1),substr(c,index(c,$3)+2,length(c)-index(c,$3)-1))
}
}
END{
split(a,arr,",")
split(b,brr,",")
split(c,crr,",")
for (i=1;i<=10;i++)
printf("%5s %5s %5s\n",arr[i],brr[i],crr[i])
}' c
rm c

  #6 (permalink)  
Old 10-05-2007
gyana_cboy gyana_cboy is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 9
Hi summer you picked the right one ....
the example is pretty good .......

Because of my busy schedule i am unable to posted the examples..
Thanks a lot
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 04:05 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