Reputation: 15
I have three text file and I want to merge (print) them in one file. using awk programme. I used the following code to print or call two different text file, and it is work perfectly. but if I have three or four text file it does not work. any idea, help
BEGIN { #1 text file
} # This line is closing the BEGIN
{
if (FNR != NR)
print $0
}
END {
print ""
} # Closing END
BEGIN { # 2 text file
} # This line is closing the BEGIN
{
if (FNR == NR)
print $0
}
END {
Upvotes: 1
Views: 29
Reputation: 67497
you don't need awk
for this, cat
is the right tool
$ cat file1 file2 file3 > mergedfile
but, of course awk
will do as well
$ awk 1 file1 file2 file3 > mergedfile
Upvotes: 1