![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 extract first column with a specific character | selamba_warrior | Shell Programming and Scripting | 3 | 05-22-2008 05:14 AM |
| How to extract only first column from the file | selamba_warrior | Shell Programming and Scripting | 11 | 05-21-2008 02:52 AM |
| column extract help | cvm | Shell Programming and Scripting | 1 | 04-24-2008 04:19 PM |
| Extract column data from File | sudheshnaiyer | UNIX for Dummies Questions & Answers | 3 | 10-11-2007 09:52 PM |
| extract column based on name | t27 | UNIX for Dummies Questions & Answers | 3 | 08-29-2007 01:04 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to extract a column from two different files in AWK?
Hi guys,
I need help in extracting one column of numbers from two different files and display it in a output file. In specific, I want to extrac the column no.2 ($2) from each file, file1.txt, file2.txt. Then place both extracted columns in a one file, out.txt. the line command I use to call the AWK code and the files is this: awk -f code.awk file1.txt file2.txt > out.txt code.awk I have is (and is worng! ): #Extracting columns # BEGIN {} #{print $2 < file1.txt , $2<file2.txt} END {} I appreciate a lot your kind help, solracq, |
|
||||
|
If your shell supports it:
Code:
paste <(cut -f2 file1.txt) <(cut -f2 file2.txt) Code:
cut -f2 file1.txt >tmp cut -f2 file2.txt | paste tmp - |
|
||||
|
Quote:
the output should be the column#2 of file 1, Tab, the column #2 of file 2 file1 1 2 2 3 3 4 file2 5 8 6 9 7 10 output 2 8 3 9 4 10 thanks!, solracq |
|
||||
|
Quote:
IT WORKS...! THANKS A LOT !!! solracq p.s. also thx to to the ppl who answered my question! |
| Sponsored Links | ||
|
|