How to run a .awk file?

后端 未结 3 1951
轮回少年
轮回少年 2021-02-03 23:19

I am converting a CSV file into a table format, and I wrote an AWK script and saved it as my.awk. Here is the my script:

#AWK for test
awk -F , \'
    BEGIN {
           


        
3条回答
  •  没有蜡笔的小新
    2021-02-04 00:04

    If you put #!/bin/awk -f on the first line of your AWK script it is easier. Plus editors like Vim and ... will recognize the file as an AWK script and you can colorize. :)

    #!/bin/awk -f
    BEGIN {}  # Begin section
    {}        # Loop section
    END{}     # End section
    

    Change the file to be executable by running:

    chmod ugo+x ./awk-script
    

    and you can then call your AWK script like this:

    `$ echo "something" | ./awk-script`
    

提交回复
热议问题