Grep all string which do not starts with number(s)

grepregular expression

I'm looking for grep to show all characters which do not starts with numbers.
I have done something like this:

grep -v '^[1-2]*[a-zA-Z]?' -o

but it do not work.
Do you have any idea for some reg exp?

Best Answer

grep -v '^[0-9]'

Will output all the lines that do not (-v) match lines beginning ^ with a number [0-9]

For example

$ cat test
string
string123
123string
1string2
$ grep -v '^[0-9]' test
string
string123

or if you want to remove all the words that begin with a digit

sed 's/[[:<:]][[:digit:]][[:alnum:]_]*[[:>:]]//g'

or with shortcuts and assertions

sed 's/\<\d\w*\>//g'

For example

$ cat test
one
two2
3three
4four4
five six
seven 8eight
9nine ten
11eleven 12twelve
a b c d
$ sed 's/[[:<:]][[:digit:]][[:alnum:]_]*[[:>:]]//g' test
one
two2


five six
seven 
 ten

a b c d
Related Question