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

Using standard input with names in AWK

Sometimes, we may need to read input from standard input and from the pipe. The way to name the standard input, with all versions of AWK, is by using a single minus or dash sign,  -.  For example:

$ cat cars.dat | awk '{ print }' -

This can also be performed as follows:

$ cat cars.dat | awk  '{ print }'  /dev/stdin ( used with gawk only )

The output on execution of this code is as follows:

maruti          swift       2007        50000       5honda           city        2005        60000       3maruti          dezire      2009        3100        6chevy           beat        2005        33000       2honda           city        2010        33000       6chevy           tavera      1999        10000       4toyota          corolla     1995        95000       2maruti          swift       2009        4100        5maruti          esteem      1997        98000       1ford            ikon        1995        80000       1honda           accord      2000        60000       2fiat            punto       2007        45000       3

We can also first read the ...

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