join two column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting join two column
# 1  
Old 02-27-2012
Bug join two column

Hi

I want to join last two column:

File A
Code:
U3268 2689 61 12 10
U3268 2684 71 13 0
U3268 2685 81 13 1

Output:
Code:
U3268 2689 61 12/10
U3268 2684 71 13/0
U3268 2685 81 13/1

Thanks

Last edited by Franklin52; 02-27-2012 at 03:16 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 02-27-2012
Code:
awk '{$4=$4"/"$5;$5="";}1'  fileA

Guru.
This User Gave Thanks to guruprasadpr For This Post:
# 3  
Old 02-27-2012
Code:
$ awk '{$(NF-1)=$(NF-1)"/"$NF;$NF="";print}' test.txt
U3268 2689 61 12/10 
U3268 2684 71 13/0 
U3268 2685 81 13/1

This User Gave Thanks to itkamaraj For This Post:
# 4  
Old 02-27-2012
Using sed - and assuming last column has only numbers
Code:
sed 's/ \([0-9]*\)$/\/\1/g' infile

Use -i option to make the changes inline

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 5  
Old 02-27-2012
Code:
sed 's! !/!4' file

This User Gave Thanks to Franklin52 For This Post:
# 6  
Old 02-27-2012
Alternate Sed..
Code:
sed 's/ \([^ ]*\)$/\/\1/' inputfile

This User Gave Thanks to michaelrozar17 For This Post:
# 7  
Old 02-27-2012
Thanks a lot GuysSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Join with awk different column

hi guys, i need help I need to join file2 to file1 when column 3 in my file1 and column 1 in my file2 in the same string file1 AA|RR|ESKIM RE|DD|RED WE|WW|SUPSS file2 ESKIM|ES SUPSS|SS Output AA|RR|ESKIM|ES RE|DD|RED| WE|WW|SUPSS|SS (3 Replies)
Discussion started by: radius
3 Replies

2. Programming

Update a column from a Join

Here is my select that I have to identify the child records that are Open (e.c7 < 6000) when the parent (t2068) c.c7 > 3 SELECT c.c1000000161, c.c7, c.c1000000019, e.c1000000829 FROM t2068 c INNER JOIN t1533 e ON e.c1000000829 = c.c301572100 where c.c7 > 3... (2 Replies)
Discussion started by: newborndba
2 Replies

3. UNIX for Dummies Questions & Answers

Join 2 files based on certain column

I have file input1.txt 11103|11|OTTAWA|City|AA|CAR|0|0|1|-1|0|8526|2014-09-07 23:00:14 11103|11|OTTAWA|City|BB|TRAIN|0|0|2|-2|6|6359|2014-09-07 23:00:14 11104|11|CANADA|City|CC|CAR|0|0|2|-2|0|5947|2014-09-07 23:00:14 11104|11|CANADA|City|DD|TRAIN|0|0|2|-2|1|4523|2014-09-07 23:00:14... (5 Replies)
Discussion started by: radius
5 Replies

4. Shell Programming and Scripting

Multi column join

Hello folks, having a new problem with an old solution I previously had working, but think i'm missing something here. File1: 900001093|HAMU1|SUDO_ALIAS 100100361|IAM_IDS|SUDO_ALIAS 100100361|AMPF|SUDO_ALIAS File2: ABC123456|Cust1|900001093|myemail@here.com|Jane Smith|Win1|hamu1... (2 Replies)
Discussion started by: dagamier
2 Replies

5. UNIX for Dummies Questions & Answers

Join files by second column

I have file input file1 1/1/2013 A 553.0763397 96 16582 1/1/2013 B 459.8333588 195 11992 1/2/2013 A 844.2973022 306 19555 1/2/2013 B 833.9300537 457 20165 1/3/2013 A 563.6917419 396 13879 1/3/2013 B 632.0749969 169 ... (1 Reply)
Discussion started by: radius
1 Replies

6. 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

7. Shell Programming and Scripting

join two files based on one column

Hi All, I am trying to join to files based on one common column. Cat File1 ID HID Ab_1 23 Cd 45 df 22 Vv 33 Cat File2 ID pval Ab_1 0.3 Cd 10 Vv 0.0444 (3 Replies)
Discussion started by: newpro
3 Replies

8. Shell Programming and Scripting

Join and awk max column

Hi Friends, I have a file1 with 3400 records that are tab separated and I have a file2 with 6220 records. I want to merge both these files. I tried using join file1 and file2 after sorting. But, the records should be (3400*6220 = 21148000). Instead, I get only around 11133567. Is there anything... (13 Replies)
Discussion started by: jacobs.smith
13 Replies

9. Shell Programming and Scripting

Join 3 or more files using matching column

Dear Forum, Full title of the topic would be: "Join 3 or more files using matching column without full list in any of these columns" I have several, typically 3 or 4 files which I need to join, something like FULL JOIN in slq scripts, all combinations of matches should be printed into an... (3 Replies)
Discussion started by: cyz700
3 Replies

10. UNIX for Dummies Questions & Answers

Join 2 files using first column

Hi, I'm trying to compare the first column of two files (tab or whitespace delimited, either way's fine, I`ve got both) and print the lines that are identical for the first column of both files. Something like this: File1 AAA 26 49 7 27 36 33 46 75 73 69 AAAAA 4 10 4 7 10 18 21... (2 Replies)
Discussion started by: vanesa1230
2 Replies
Login or Register to Ask a Question