Help me to write the script


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
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  
Please give us an example.
# 3  
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  
Please give us a full example.
Input files with many rows, and expected output file.
# 5  
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  
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
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #31
Difficulty: Easy
Alan Turing was the founder of IBM.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Please write a script for me

Hi All, need one help Suppose there are two files- 1)Input files-: path1/given/to/file | File1 path2/given/to/file | file 2 etc Note- I use "|" as variable separator. 2) Target files- I want to fetch data from file1 and use in below command-: cd /path(from 1st file) ls -ltr If file(From... (2 Replies)
Discussion started by: Shubham
2 Replies

2. Shell Programming and Scripting

Need help to write script

I am having a File format as mentioned below Employee id|Name|Languages 12345|Hema|02|English|Hindi 4567|Basha|03|Engligh|Hindi|Telegu the 02 and 03 are counters. Using that we need to generate the output records as mentioned below 12345|Hema|English 12345|Hema|Hindi ... (8 Replies)
Discussion started by: bashamsc
8 Replies

3. Shell Programming and Scripting

Need to write a script...

Hello all, I am new to shell scripting. I want to write a shell script which will give me the output of the following query as an attachment in a mail SELECT /*+ parallel(a,4)*/ban, subscriber_no, business_id, price_plan_code, call_action_code, special_seq_no, toll_soc, toll_feature_code,... (1 Reply)
Discussion started by: paraspawar
1 Replies

4. Shell Programming and Scripting

Please help me to write the script

Hi All, I have written the follwing script to take the backup of the file every day along with the date. DATE=`date +%Y%m%d` export DATE cp var/hr/hr333m.txt cp var/hr/payments/hr333m_$DATE.txt The file name as follows after taking the backup. hr333m_20110630.txt Could you... (3 Replies)
Discussion started by: ajaykumarkona
3 Replies

5. Shell Programming and Scripting

write a script

Dear Madam/Sir Who can help me with writing a script doing the following? 1- Read names of files (only files with special name format let say initially they have the same file name start like TT*) 2- Then create an empty files with the same names have been read in step one but with extension... (4 Replies)
Discussion started by: m.nageeb
4 Replies

6. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

7. Shell Programming and Scripting

Better way to write this script

Hi All, I have written the following script. I have just repeated some commands, and I am sure there is a more better way to do it. I hope I one of gurus here will help me make it in a better shape. Here is the script: #! /bin/sh sed -i -e "s/test2.xxx/test3.xxx/" -e "s/output2/output3/"... (2 Replies)
Discussion started by: faizlo
2 Replies

8. UNIX for Dummies Questions & Answers

Should I write a PERL Script or Shell Script?

Hello, I have done some BASIC shell scripting/PERL scripting before so I am familiar with the languages. I am not really sure which one would lend itself better to the application I have to write. I am required to scan the message logs for possible break in attempts. If I use shell scripting... (2 Replies)
Discussion started by: mojoman
2 Replies

9. Shell Programming and Scripting

Please write this script for me

UNIX shell script (Bourne shell syntax) called admin_script. This script is described below as a usage summary: admin_script Note: if no options are specified, a menu is displayed which allows users to perform one of the following tasks and then exit. If incorrect options are provided,... (1 Reply)
Discussion started by: nadman123
1 Replies

10. Shell Programming and Scripting

Help! Need to write my first script

Hi Folks! I am a MacUser and am trying to learn Unix for the last few months. I will explain in detail what I am trying to do, and apreciate you help if you can teach me even if it is a single comand line inside the script. I own a small company, where I manufacture special gypsums and... (5 Replies)
Discussion started by: fundidor
5 Replies

Featured Tech Videos