Help with grep, or alternative

say I have a big list of something like:

sdg2000
weghre10
fewg53
gwg99
jwegwejjwej43
afg10293

I want to remove the numbers of any line that has letters + 1 to 4 numbers

output:

sdg
weghre
fewg
gwg
jwegwejjwej
afg10293

Any attempts/ideas/thoughts from your side?

I have not tried, I don't know if grep can do that or not.. I know I can code it in VB6 but I also know the file size will not be supported.

The file size is 6.42 GB

Well, would this come close:

sed '/[[:digit:]]\{5,\}/ !{/[[:alpha:]]/s/[[:digit:]]\+//}' file
sdg
weghre
fewg
gwg
jwegwejjwej
afg10293

That worked great! Thank you.

A few Perl alternatives.

Any of:

perl -pe 's/([a-zA-Z])\d{1,4}$/$1/' siwon.file
perl -pe 's/(?<=[a-zA-Z])\d{1,4}$//' siwon.file
perl -pe 's/([a-zA-Z])\d{1,4}(?!\d)/$1/' siwon.file
sdg
weghre
fewg
gwg
jwegwejjwej
afg10293

Are the numbers always after the letters? In this case

egrep -v '[a-zA-Z][0-9]{1,4}'

should do it. Note that this assumes just plain ASCII letters. If you are worrying about other letters (accented characters, japanese text and so on), you can use character class expressions, and to what extend you have them available, depends on your grep version. Look at the grep manpage for details.

awk '{n=gsub(/[0-9]/, "&")} /[a-zA-Z]/ && n < 5 {gsub(/[0-9]/, "")} 1 ' infile