how to insert one file into another file not by concatenating as usual done.
file1
A B
C D
E F
G H
I J
K L
file2
23455
33444
33334
33345
Output shud be
23455
A B
C D
33444
E F
G H
33345
I J
K L
how to insert one file into another file not by concatenating as usual done.
file1
A B
C D
E F
G H
I J
K L
file2
23455
33444
33334
33345
Output shud be
23455
A B
C D
33444
E F
G H
33345
I J
K L
probably an easier way than this, but it does work :
# paste -s -d "\t\n" file1 | paste file2 - | tr "\t" "\n"
23455
A B
C D
33444
E F
G H
33334
I J
K L
33345
also - can use cat for legibility:
# cat file1 | paste - - | paste file2 - | tr "\t" "\n"
does same as 1st ans..
33334
I J
K L
33345
[/CODE]
[/quote]
Thanks.....
awk 'FNR==NR{ a[FNR]=$0;next }
{
print $0
print a[FNR+l]
l++
print a[FNR+l]
}
' file file1
output
# ./test.sh
23455
A B
C D
33444
E F
G H
33334
I J
K L
33345