problen with a join under AIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problen with a join under AIX
# 1  
Old 03-02-2005
problen with a join under AIX

Hello,

I have a script shell under aix with a join of 2 files
fic2.txt :
test100:zone 1 :zone 2:zone 3
test10:zone 1:zone 2:zone 3
test:zone 1:zone 2:zone 3
fic3.txt:
test100:zone 4:zone 5
test10:zone 4:zone 5
test:zone 4: zone 5

and the command : join -11 -21 -t: fic2.txt fic3.txt

gives back only the line
test100:zone 1 :zone 2:zone 3:zone 4:zone 5

and not the lines
test100:zone 1:zone 2:zone 3:zone 4:zone 5
test10:zone 1:zone 2:zone 3:zone 4:zone 5
test:zone 1:zone 2:zone 3:zone 4:zone 5
like I was waiting for. Why ???? Do you have a solution ?

Thanks for your answers

Thierry
# 2  
Old 03-02-2005
In Linux join command is working fine. I don't AIX platform to check so that Lets try with awk command as,

Code:
awk '{ getline var < "./test1";print var" "$2" "$3 }' test2

Where test1 is the first file and test2 is second file.

Check this.

HTH.
# 3  
Old 03-02-2005
Hi muthukumar,

Thanks for your answer, but it don't works. I have, effectively 3 lines corresponding, but I have lost a part of fic3 (the word 'zone')

test100:zone 1 :zone 2:zone 3 4:zone 5
test10:zone 1:zone 2:zone 3 4:zone 5
test:zone 1:zone 2:zone 3 4: zone

And more, this is an example, but the original file fic2 may have differents lines like the following

test100:zone 1 :zone 2:zone 3
test100:zone11:zone22:zone33
test10:zone 1:zone 2:zone 3
test:zone 1:zone 2:zone 3

So the result with the join should be

test100:zone 1 :zone 2:zone 3:zone 4 :zone 5
test100:zone11:zone22:zone33:zone 4 :zone 5
test10:zone 1:zone 2:zone 3:zone 4 :zone 5
test:zone 1:zone 2:zone 3:zone 4 :zone 5

but it is with your command

test100:zone 1 :zone 2:zone 3 4:zone 5
test100:zone11:zone22:zone33 4:zone 5
test10:zone 1:zone 2:zone 3 4: zone

Thierry
# 4  
Old 03-02-2005
The files must be correctly sorted into ASCII order...
Code:
$ sort -t: -k1,1 file1.txt > file1.sorted
$ sort -t: -k1,1 file2.txt > file2.sorted
$ join -t: file1.sorted file2.sorted
test:zone 1:zone 2:zone 3 :zone 4: zone 5
test10:zone 1:zone 2:zone 3 :zone 4:zone 5
test100:zone 1 :zone 2:zone 3 :zone 4:zone 5

Cheers
ZB
# 5  
Old 03-02-2005
Hi zazzybob

Thanks a lot, it works. In fact I had a sort in the script, but it was not the good one (sort -A).

I dont' know what time it is in Australia, but have good day

Thierry
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join, merge, fill NULL the void columns of multiples files like sql "LEFT JOIN" by using awk

Hello, This post is already here but want to do this with another way Merge multiples files with multiples duplicates keys by filling "NULL" the void columns for anothers joinning files file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: 1|123|jojo 1|NULL|bibi... (2 Replies)
Discussion started by: yjacknewton
2 Replies

2. UNIX for Dummies Questions & Answers

How to use the the join command to join multiple files by a common column

Hi, I have 20 tab delimited text files that have a common column (column 1). The files are named GSM1.txt through GSM20.txt. Each file has 3 columns (2 other columns in addition to the first common column). I want to write a script to join the files by the first common column so that in the... (5 Replies)
Discussion started by: evelibertine
5 Replies

3. AIX

Nim on AIX 7.1 used to migrate AIX 5.3 to AIX 6.1...is possible?

Using nimadm: nimadm -j nimadmvg -c sap024 -s spot_6100 -l lpp_6100 -d "hdisk1" -Y Initializing the NIM master. Initializing NIM client sap024. 0505-205 nimadm: The level of bos.alt_disk_install.rte installed in SPOT spot_6100 (6.1.3.4) does not match the NIM master's level (7.1.1.2).... (2 Replies)
Discussion started by: sciacca75
2 Replies

4. UNIX for Dummies Questions & Answers

how to join two files using "Join" command with one common field in this problem?

file1: Toronto:12439755:1076359:July 1, 1867:6 Quebec City:7560592:1542056:July 1, 1867:5 Halifax:938134:55284:July 1, 1867:4 Fredericton:751400:72908:July 1, 1867:3 Winnipeg:1170300:647797:July 15, 1870:7 Victoria:4168123:944735:July 20, 1871:10 Charlottetown:137900:5660:July 1, 1873:2... (2 Replies)
Discussion started by: mindfreak
2 Replies

5. Shell Programming and Scripting

AIX : Need help with <join> command in csh

Hi All, I need your hand to resolve an issue I am facing with a join command in one of the script. Please see the 3 files attached where file1 and file2 are the two files I am passing to the join command written in the command file. Prior to calling the join I am also sorting both the files on... (6 Replies)
Discussion started by: sraj142
6 Replies

6. UNIX for Dummies Questions & Answers

Join 2 files with multiple columns: awk/grep/join?

Hello, My apologies if this has been posted elsewhere, I have had a look at several threads but I am still confused how to use these functions. I have two files, each with 5 columns: File A: (tab-delimited) PDB CHAIN Start End Fragment 1avq A 171 176 awyfan 1avq A 172 177 wyfany 1c7k A 2 7... (3 Replies)
Discussion started by: InfoSeeker
3 Replies

7. Programming

sql,multiple join,outer join issue

example sql: select a.a1,b.b1,c.c1,d.d1,e.e1 from a left outer join b on a.x=b.x left outer join c on b.y=c.y left outer join d on d.z=a.z inner join a.t=e.t I know how single outer or inner join works in sql. But I don't really understand when there are multiple of them. can... (0 Replies)
Discussion started by: robbiezr
0 Replies

8. Shell Programming and Scripting

Problen in a bash script

Hi New post, and new member I have a problem with a bash script And I probably look't at for so long that I DON'T See a obvious syntax error The reason for the script is to selectively change permission, UID, GID within A selected /dir Anny help or insight would be appreciated... (2 Replies)
Discussion started by: Ex-Capsa
2 Replies

9. UNIX for Dummies Questions & Answers

Join

Hi, Is there a way to get join to join 2 files even if in one file one of the records does not exist? i.e. 1st file aaa 50 bbb 60 2nd file aaa 40 So i want to join the 2 files together and get the following output: aaa 50 aaa 40 bbb 60 bbb 0 Is this possible??? Thanks Jason (5 Replies)
Discussion started by: jazz8146
5 Replies

10. Shell Programming and Scripting

join (pls help on join command)

Hi, I am a new learner of join command. Some result really make me confused. Please kindly help me. input: file1: LEO oracle engineer 210375 P.Jones Office Runner ID897 L.Clip Personl Chief ID982 S.Round UNIX admin ID6 file2: Dept2C ID897 6 years Dept5Z ID982 1 year Dept3S ID6 2... (1 Reply)
Discussion started by: summer_cherry
1 Replies
Login or Register to Ask a Question