extract columns from 2 different files and create new file

Hi All,

I have 2 issues while working with file.

  1. I have 2 delimited(~) files. I want to extract column numbner 3 from file1 and column number 8 from file2 and paste it into file3. I have tried using cut, but not able to get answer.

  2. i have 2 filxed-width file. I wanted to do same task as above for these files.

Could you please let me which command we need to use.

considering the files are of the same lengh(records) [ not tested]

nawk 'BEGIN{FS=OFS="~";i=1;j=1}
FILENAME == "file1" {
a=$3
i++
next
}
FILENAME == "file2" {
b[j]=$8
j++
next
}
END{
for ( i in a)
print a,b 
} ' file1 file2 > file3

cheers,
Devaraj Takhellambam