|
This script makes the ASSUMPTION that f1.txt and f2.txt have the same number of records ie the line count is the same.
Failure to maintain this will cause undefined output.
[root@lima awk]# cat prog.awk
BEGIN {FS=",";ORS=""}
{
if (FILENAME==ARGV[1]) {
getline <ARGV[1]
print $2,$3,""
getline <ARGV[2]
print $2,"\n"
} else {
exit
}
}
[root@lima awk]# cat f1.txt
q,w,e,r
a,s,d,f
z,x,c,v
[root@lima awk]# cat f2.txt
r,t,y
f,g,h
v,b,n
[root@lima awk]# awk -f prog.awk f1.txt f2.txt > f3.txt
[root@lima awk]# cat f3.txt
w e t
s d g
x c b
[root@lima awk]#
|