Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

awk and arrays

Options
  • 26-09-2011 4:09pm
    #1
    Registered Users 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