Results 1 to 6 of 6

Thread: awk

  1. #1
    Join Date
    Jan 2004
    Posts
    84

    Unanswered: awk

    echo $LINE | awk '{print $3}' is 97% but I want only 97 for computation... how do i extract " % "

  2. #2
    Join Date
    Jan 2004
    Posts
    84
    I mean I want 97 only and not % sign with it for computation

  3. #3
    Join Date
    Feb 2004
    Location
    Eternity
    Posts
    31
    Try
    echo $line | awk '{print $3}' | cut -d"%" -f1

    Thanx
    Vijay

  4. #4
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    echo $LINE | awk '{sub(/%/,"",$3) ; print $3}'
    Jean-Pierre.

  5. #5
    Join Date
    Jan 2004
    Posts
    84
    what is f1 for?
    Thanks anyways..

  6. #6
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    cut -d"%" -f1

    -d"%" Specify field delimitor as "%"
    -f1 Get field 1
    Jean-Pierre.

Posting Permissions

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