Sed one-liner to remove all 0-9 digits that occur after a period

I have

sed -e '/^ *[0-9]\+ *$/d' <oldtextfile >newtextfile

... which I use in the text that I copied and pasted from PDF files to remove page numbers. However, I also need to delete the footnote numbers, so I need to change the sedone - line above to do this by deleting any numbers that occur after the period, and unfortunately I have very little patience for sed. Can someone help me?

+3
source share
5 answers
sed 's/\.[0-9]*/./g'

This probably does not do what you want to do, so more accurately say what you want to do.

+7
source

Windows sed , + -\+. : http://www.gnu.org/software/sed/manual/sed.html#Regular-Expressions

, geofftnz :

C:\Users\Me>cat test.txt | sed "s/\.[0-9]\+//g"
+2

sed, , , :

cat test.txt | sed "s/\.[0-9][0-9]*//g"

( sed + )

C:\Users\Me>cat test.txt
Hello, this is a file
with some .2346 stuff I want to remove.

.this stuff I dont.

What about some more: .99123how that?

Normal number: 1234

C:\Users\Me>cat test.txt | sed "s/\.[0-9][0-9]*//g"
Hello, this is a file
with some  stuff I want to remove.

.this stuff I dont.

What about some more: how that?

Normal number: 1234
+1

- , , , , .

: foo123.bar465baz789qux

, awk

awk -F'.' '{gsub("[[:digit:]]","",$2)}1' OFS='.' oldtextfile > newtextfile

$ echo "foo123.bar456baz789qux" | awk -F'.' '{gsub("[[:digit:]]","",$2)}1' OFS='.'
foo123.barbazqux
0

, ,

cat yourfile.txt| |tr -d "[0-9]" > newfile.txt
0

All Articles