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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

AWK?

  • 09-06-2010 10:34am
    #1
    Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭


    Not sure if this is the correct place for this but here it goes:

    I need a, what you would think is easy, awk command to pipe a result to then print from a certain feild to the end, including that feild. So a psudeo sample might be:

    ls -l *.log | awk '{print $8,EOF}'


    I can easliy do this with cut but I need it to be awk!

    BTW, I can easily make $1="",$2="" etc up to the start column but that is a little tedious.


Comments

  • Registered Users, Registered Users 2 Posts: 2,370 ✭✭✭Knasher


    If I understand you correctly then you are trying to print from a certain column on in a row across a number of files.

    In which case try:
    awk '{ for(i = <whatever column number you want, starting from 1>; i <= NF; i++){ printf "%s\t", $i; } printf "\n"; }' *.log
    

    Unless you are trying to only print the results of an ls, in which case piping like you are doing should be fine into the command I've specified. Sorry if this isn't the most efficient method, I'm still pretty new to awk myself.


  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    Thanks.
    I had been playing around with something similar except it seems to output on new lines instead of together, nightmare.


Advertisement