O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appending output to a file (>>)

This redirection operator appends the output to file. It's syntax is as follows:

print items >> demo

In this type of redirection, items are appended into the preexisting output file named demo. Here, while performing the redirection the output file is not erased. If the output file does not exist, then it is created. For example, now we append the content at the end of the file (emp_report) created using the printf_rediection1.awk using redirection operator (>>), as follows:

$ vi printf_append.awkBEGIN    {    printf "=========employee database ends here=============\n" >>"emp_report"
    }$ awk -f printf_append.awk

On execution of preceding code, it will append the line in the existing file, emp_report, which was created ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required