Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

awk and arrays

  • 26-09-2011 04:09PM
    #1
    Registered Users, Registered Users 2 Posts: 85 ✭✭


    Hi everyone,

    I am having a problem with awk.

    I have a file of which I want to print only certain lines.

    The lines to print are determined by an array.

    so something like

    for runs in ${options[@]}
    do
    awk 'NR==$runs' '{getline; print $0}' myfile
    done


    in options would be something like {1 2 3}, which would mean that in this case I want to print the 1st, 2nd and 3rd line of myfile

    This code does not work, it does absolutely nothing.
    Does anyone have an idea?
    Tagged:


Advertisement