[lug] delete last character of every line
Calvin Dodge
caldodge at fpcc.net
Wed Mar 23 16:14:35 MST 2005
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
--
Calvin Dodge
Certified Linux Bigot (tm)
http://www.caldodge.fpcc.net
More information about the LUG
mailing list