Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove trailing spaces from records

Status
Not open for further replies.

mwesticle

Programmer
Nov 19, 2003
51
US
If I have a file where all of the records have trailing spaces... like this (without the single quotes):

'123 Main '
'456 Central Ave '
'789 Oak Street '

How do I take this file, and strip the trailing spaces, so my output looks like this (without the single quotes):

'123 Main'
'456 Central Ave'
'789 Oak Street'

Any takers?
 
Try something like this:
sed -e 's! *$!!' /path/to/input >output

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Hi:

You can also use a while loop:

while read line
do
echo $line
done < olddata > newdata

This may not work with all unix variants, but it works with my Solaris 7 ksh.

Regards,

Ed



 
olded, this will also get rid of leading spaces and compress all sequence of consecutive spaces to one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top