![]() |
|
|
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 |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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.. |
|
||||
|
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 . |
|
||||
|
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
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|