Running AWKscripts from the Command Line in a Terminal Window

Actually the first step is to create or edit the text input file for the specific awkscript you are going to run, using a simple text editor (gedit, kedit, whatever). Note that this is not the awkscript itself, it is the input file that the script will read in. That window will look something like this.....

png

Save the edited file to the same folder the awkscript is in. Then open a terminal window on your desktop. This can usually be done from your desktop's main toolbar, something like APPLICATIONS > ACCESSORIES > TERMINAL.

In the terminal window, cd into the folder that contains the awkscript and the input file you just edited. Type in this command....

awk -f awkscriptname inputfilename

but use the correct names for the two files (including their extensions).

The awk output will be written to the screen, and it will look something like this......

png

If you want the output written to a file, rather than the screen, use this command ....

awk -f awkscriptname inputfilename > outputfilename

The output file, when opened in a text editor will look like this....

png

The awkscript file in this case is here.




Tikmark Home Page