Find the answer to your Linux question:
Results 1 to 2 of 2

Thread: awk script help

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    awk script help

    i'm trying to convert this awk command from command line into an awk script, but just cannot get it to work:

    awk -F: '$5 ~ /A/ {Acount++; print Acount}' file

    this is what i have after my BEGIN

    $5~/A/Acount++ {print Acount}

    am i missing something here? this just prints out the count for everyline, not counting lines on 5th field that match 'A'

    any help is appreciated.

  2. #2
    Your script should look like this:

    /path/to/awk -f
    BEGIN {
      FS = ":"
    $5 ~ /A/ {
    END {
      print Account
    And you should invoke it like this:

    awk -f <script_name> <input_filename>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts