The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-28-2008
solracq solracq is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 8
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,