Find the answer to your Linux question:
Results 1 to 4 of 4
Hi , I have written following statement to get the value from a footer file LCNT2=`awk -F "|" '{ print $2}' footer.txt` but its giving an junk value while I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2007
    Posts
    18

    Red face awk command Error


    Hi ,

    I have written following statement to get the value from a footer file

    LCNT2=`awk -F "|" '{ print $2}' footer.txt`
    but its giving an junk value while I am testign thru Shell scripting

    Error is:
    + LCNT2=$'9\r'
    which is supposed to be 9.

    Can you please help me out,

    Many Thanks,
    Vishnu

  2. #2
    Just Joined!
    Join Date
    Feb 2007
    Posts
    18
    could any one please help me out! I am all most stuck with this issue.

    Many Thanks,
    Vishnu.

  3. #3
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    There's a carriage return appended to the value.

    Try:
    Code:
    gawk -F "|" '{ sub("\r$", "", $2); print $2}' footer.txt
    to strip it.

  4. #4
    Just Joined!
    Join Date
    Feb 2007
    Posts
    18
    Thanks a lot for your help! its working..


    Kind Regards,
    Vishnu.

Posting Permissions

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