Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

i have a very, very, very long list. Like over 830,000 characters. I will of course perform said command on a copy.

There are multiple lines, like this

hey1=lol
hey2=lol
hey3=lol

I want that to turn out like this

hey=lol
hey=lol
hey=lol

This must be possible with sed, awk or similar?

The reason im not using Sumblime text is because all lines do not have a number before them.

share|improve this question

2 Answers 2

You can use sed:

sed -e 's/[0-9]*=/=/' < data

This replaces (s) any text that is zero or more characters in the range 0-9 followed by an = sign with just the = sign.

share|improve this answer
    
s/[0-9]+=/=/ might be easier to mentally map to the OP's request, but either should work just as well. Also, I'd probably redirect the output to a file too. :) Even so, +1. –  Michael Kjörling Aug 9 at 22:10
    
+ is annoyingly non-standard. –  Michael Homer Aug 9 at 22:12
    
just for completeness' sake you can also use [:digit:] as in sed -e 's/[:digit:]*.=/=/g' < data –  Dani_l Aug 9 at 22:47
3  
@Dani_l, you have to put the character class inside brackets: s/[[:digit:]]*=/=/ –  glenn jackman Aug 9 at 23:17
    
@glennjackman did you try my solution? both work. Don't forget the period "." after the star "*". –  Dani_l Aug 14 at 14:48

If you want to remove every number that comes before '='

awk -F= '{gsub(/[[:digit:]]/, X, $1)}1' OFS== file

Above code satisfies even if there multiple numbers scattered before '='

hey1=lol
h9e7y2=lol
1hey3=lol
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.