Find the answer to your Linux question:
Results 1 to 2 of 2
Hi , I want to read a file and pass the string to another job ,File has values like "000TV,000TX,000TZ,000WG," This is generated dynamically so there is no predefined length, ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    1

    Remove a space at the end of line

    Hi ,
    I want to read a file and pass the string to another job ,File has values like "000TV,000TX,000TZ,000WG," This is generated dynamically so there is no predefined length, Now what I want is to remove "comma" at the last position.
    so output will be "000TV,000TX,000TZ,000WG"

    I am a newbie, I tried to use SED,WC -m, etc but in vain.

    please suggest me..

    Thanks in Advance
    shiva

  2. #2
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    with sed, you can do
    sed 's/\(.*\),/\1/g' datafile

    or you can:
    cat datafile | while read line; do line=${line%,}; echo $line; done

Posting Permissions

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