[lug] delete last character of every line

Shannon Johnston sjohnston at cavionplus.com
Thu Mar 24 09:04:12 MST 2005


It never ceases to amaze me how many different ways you can use the same
command to achieve a desired result.

cat with sed worked for me. Thanks for the help!

Shannon


On Wed, 2005-03-23 at 16:14 -0700, Calvin Dodge wrote:
> On Wed, Mar 23, 2005 at 02:33:54PM -0700, Shannon Johnston wrote:
> > Once again, I'm stuck with a little problem.
> > I've got a list of 6000 ip addresses in a text file, all of them have a
> > trailing ".". I need to get rid of that before it becomes useful.
> > 
> > Does anybody know how to do that? Either in vi or as a sed command?
> 
> Hmmm ... if the format is "nnn.nnn.nnn.nnn.", then
> cut -d '.' -f 1-4 FILENAME >newfile
> 
> Another way - if there are no spaces in the lines, is:
> 
> (for n in $(cat FILENAME);do echo ${n%\.};done) >newfile
> 
> But since you asked for sed, I finally broke down and tried that (I'm
> not a sed expert):
> 
> sed -e 's/\(.*\)\./\1/' FILENAME >newfile
> 
> Calvin
> 




More information about the LUG mailing list