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, ...
- 09-09-2008 #1Just 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
- 09-11-2008 #2Linux 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


Reply With Quote