Korn shell Script to combine Two files in one


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Korn shell Script to combine Two files in one
# 1  
Old 04-10-2017
Korn shell Script to combine Two files in one

Hello All , I am new to this Forum,
I am trying to write a script to combine two data files with 1 column in common and others columns are different .
File1
Code:
Apple     29
tomatao  4
grapes    25

File2
Code:
Apple     fruit
tomatao  veg
grapes    fruit
             other


Last edited by vgersh99; 04-10-2017 at 01:44 PM.. Reason: code tags, please!
# 2  
Old 04-10-2017
And what do you want the output to look like?
Combine could mean many different things.
# 3  
Old 04-10-2017
The out put should be in third file as below

Code:
Apple      29        Fruit
tomato     4         vegetable
grapes    25       Fruit
                       other


Last edited by vgersh99; 04-10-2017 at 03:36 PM.. Reason: the other should be in third column - code tags, please!
# 4  
Old 04-10-2017
Consider the join command
Code:
man join

This User Gave Thanks to MadeInGermany For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combine shell files

I am hoping the attached shell file is at least somewhat close to this. Combining two shell file into one, where depending on the user input of"y" or "n" different commands are run. Thank you :). So first he user is asked for an ID to match, once the id is entered a script is run that uses... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Combine shell files

The script below is an attempt to combine 3 shells into 1. The first part: match.sh prompts the user for an id of a patient and runs a match script based on the response of "y" or "n". After completing the user is asked if there are additional patients, and based on "y" or "n" a certain action... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

Korn shell script to sync/move files that are not in use

Hello all. This may seem like a dumb/easy question but right now I have a little script I made that uses rsync to sync a directory that has files in it that may or may not be complete files. I want to come up with a better solution for this. What it is is I have a directory lets say /incomplete... (4 Replies)
Discussion started by: linuxn00b
4 Replies

4. UNIX for Dummies Questions & Answers

Combine two files using shell script

I need to combine two files based on the content in first column and combine it into one file . For example : file1: A 10 B 20 C 30 D 40 File2: B 200 E 500 A 100 D 400 Need the output in this format: file 3 : column 1 Column 2 Column 3 A 10 100 B 20 ... (4 Replies)
Discussion started by: tsm2011
4 Replies

5. Shell Programming and Scripting

how to combine two files into one file using shell scrip

eg. file 1 has: 4 0 8628380 653253 0 0 0 0 0 0 2 0 8626407 655222 0 0 0 0 0 0 4 0 8633729 647892 0 0 0 0 0 0 5 0 8646253 635367 0 0 0 0 0 0 file 2 has: 4798 48717 11554 5408 56487 14359 6010 58415 15220 5541 41044... (2 Replies)
Discussion started by: netbanker
2 Replies

6. Shell Programming and Scripting

combine 3 excel files using shell.

Is there any way to combine 3 excel files into one comma separated file, after removing the header row from all the three files. Is this possible? I have looked in FAQ and I did not find anything. Appreciate any suggestions or links to resources. Radhika. (11 Replies)
Discussion started by: radhika
11 Replies

7. UNIX for Dummies Questions & Answers

Korn shell awk use for updating two files

Hi, I have two text files containing records in following format: file1 format is: name1 age1 nickname1 path1 name2 age2 nickname2 path2 file 1 example is: abcd 13 abcd.13 /home/temp/abcd.13 efgh 15 efgh.15 /home/temp/new/efgh.15 (4 Replies)
Discussion started by: alrinno
4 Replies

8. UNIX for Dummies Questions & Answers

Lookup between 2 files ( korn shell )

Hi All., i have a problem. I hope i can get some help on this issue here; i have 2 txt files say file1 and file 2 file1 has; WLMT:XXXXXXXX:cp DOLR:YYYYYYY:ascii,unblock WLG:TTTTTTT:dd:73:ascii,unblock MAR:SSSSSS:dd:152:ascii,unblock GGG:QQQQQQQQQQ:112:ascii,unblock EIE:CCCCCCCC:cp... (17 Replies)
Discussion started by: pavan_test
17 Replies

9. Shell Programming and Scripting

How to process multiple files in Korn Shell

How do I make the below ksh to process all of the files inside a user specified directory? Currently it can only process one file at a time. #!/bin/ksh tr -s '\11 ' ' ' < $1 > temp0 sed -e 's/,//g' temp0 > temp1 cut -d' ' -f1,4,5 temp1 > final_output rm temp0 temp1 (3 Replies)
Discussion started by: stevefox
3 Replies

10. Shell Programming and Scripting

korn shell + sftp + list files

Hello!!! I need a korn shell script in AIX that inside sftp environment, changes a remote directory, lists the files inside it, and stores in an array. I got it working before make a sftp, but after.. I can't.. The way it is, it lists the files in local path... so.. not what I want, but... (1 Reply)
Discussion started by: alienET
1 Replies
Login or Register to Ask a Question