Find the answer to your Linux question:
Results 1 to 3 of 3
hi! I have a file with more lines and columns but not all columns are the same. For example: this is a word this is a big world is this ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    48

    Question about AWK

    hi! I have a file with more lines and columns but not all columns are the same.
    For example:

    this is a word
    this is a big world
    is this a very big world
    etc..

    How can I use awk to show the second and more character to the end?
    I use this command actually:

    Code:
    more files.log | awk '{print "ls \"/home/" $1 "/" $2 "/\"*\"" $3  "\" | wc -l"}'
    how can i put the $3 to the end? (i don't say what's the end!)

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    AWK has a built in variable that's NF, which is the number of fields each line has...

    So the way to read the second last field would be $(NF - 1) the last $NF
    Make mine Arch Linux

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Posts
    48
    i don't have my linux now, but i try this reply.
    So I don't know what's the number of fields have each line.
    I give this information from a CSV file and I generate some commands to verify if the file exist or no.

Posting Permissions

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