Welcome to the new Linux Foundation Forum!

AWK Commands!

Hello Everyone, I want to know more commands except to below:
1. Printing the table line by line
2. Length
3. Printing table row-wise
4. Printing Columns
5. Non-empty Line
6. Printing Matched Pattern
7. Inbuilt Variables
8. Count
9. For

And Can anyone suggest me some examples with awk commands, I want to see and explore more about it.

Comments

  • Hi Shivam,

    Here I am sharing with you a list of AWK Command list, Which will help you check the complete list of AWK Commands.

    1. AWK Options
    $ awk options program file

    Awk can take the following options:

    -F fs To specify a file separator.

    -f file To specify a file that contains awk script.

    -v var=value To declare a variable.

    2. Read AWK Scripts
    $ awk '{print "Welcome to awk command tutorial "}'

    3. Using Multiple Commands
    $ echo "Hello Tom" | awk '{$2="Adam"; print $0}'.

    4. Reading The Script From a File
    {print $1 " home at " $6}
    $ awk -F: -f testfile /etc/passwd

    5. Awk Postprocessing
    $ awk 'BEGIN {print "The File Contents:"}
    {print $0}
    END {print "File footer"}' myfile

    6. Built-in Variables
    FIELDWIDTHS Specifies the field width.

    RS Specifies the record separator.

    FS Specifies the field separator.

    OFS Specifies the Output separator.

    ORS Specifies the Output separator.

    7. User-Defined Variables
    $ awk '
    BEGIN{
    test="Welcome to LikeGeeks website"
    print test
    }'

    8. Structured Commands
    $ awk '{if ($1 > 30) print $1}' testfile
    Visit here for more AWK commands.

Sign In or Register to comment.