Extract column and paste in another file
Hi,
I have 2 input files-file 1 and file 2 with delimiter '|'.I need to extract 3rd column from file 1 and insert it after 3rd column in file 2.With my limited awk knowledge,this is what I have so far: Code:
awk 'FS=OFS="|"{field[NR]=$3}; FS=OFS="|"{$3=($3 FS field[FNR]); print}' file1 file2 Sample data: File 1 Code:
1|2|3|4|5 Code:
a|b|c|d|e Code:
a|b|c|3|d|e |
I have now managed to correct the command to some extent. The op is now two rows- in 1st row, the $3 of file 2 has got replaced. The 2nd row has correct entries with existing $3 and extracted data inserted after $3.
Code:
awk -F"|" 'FNR==NR{field[NR]=$3}; FNR<NR{$4=field[FNR] FS $4}1;' OFS="|" file1 file2 |
sounds like a job for cut and paste.
|
All times are GMT -5. The time now is 07:15 PM. |