1752815 Members
5948 Online
108789 Solutions
New Discussion юеВ

sed | stuck

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

sed | stuck

should be easy, im trying to search for the equal sign in each line and append four nines after it.

I tried. sed s/"="/999/g but it takes out the equal sign. I want to append after the equal sign.

The input looks like this: set rlim_fd_cur=65536
UNIX IS GOOD
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor

Re: sed | stuck

Hi :

# X="set rlim_fd_cur=65536"
# echo ${X}|sed -e 's/\=/\=9999/'
set rlim_fd_cur=999965536

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: sed | stuck

I haven't tried it, but wouldn't this work:

sed s/"="/"=9999"/g


Pete

Pete
James R. Ferguson
Acclaimed Contributor
Solution

Re: sed | stuck

Hi (again):

...or if I took you too literally, then maybe you want:

# echo ${X}|sed -e 's/\=.*/\=9999/'
set rlim_fd_cur=9999

Regards!

...JRF...
Nobody's Hero
Valued Contributor

Re: sed | stuck

Close that is what I got too:

here is the output from s/"="/"=9999"/g
set rlim_fd_cur=999965536

I still have the 65536 at the end.
I need to search for the equal sign, delete everything after it and replace it with 4 9's.

sorry I wasnt clear. Im stuck.
UNIX IS GOOD
James R. Ferguson
Acclaimed Contributor

Re: sed | stuck

Hi:

> I need to search for the equal sign, delete everything after it and replace it with 4 9's.

That's what I meant when I said I think I took you too literally :-) See my post immediately before yours.

echo ${X}|sed -e 's/\=.*/\=9999/'
set rlim_fd_cur=9999

Regards!

...JRF...
Nobody's Hero
Valued Contributor

Re: sed | stuck

Perfect James, thanks,
now what if each input line might have different numbers after the '=' sign.
is there a way I can delete whatever is after the '=' sign and replace it with 4 9's ?

you guys are good. I feel stupid.
UNIX IS GOOD
Nobody's Hero
Valued Contributor

Re: sed | stuck

Thanks James. PERFECT...man that looked easy and I was really stuck......

Thanks again really.
UNIX IS GOOD
Nobody's Hero
Valued Contributor

Re: sed | stuck

you know, you guys and gals should get more than points for helping us novice script writers.
actually I think even if I did write scripts all the time they would be half a mess.

looked so easy but I found it difficult. probably because 22% of my brain is clogged with malted hopps from vegas last week.
thats my excuse anyway.

Thanks James, you have helped me many times over the years. your company should be proud to have you on staff.

Thanks.
UNIX IS GOOD
Dennis Handly
Acclaimed Contributor

Re: sed | stuck

It turns out there is a command to make these changes in files: ch_rc(1M)

>now what if each input line might have different numbers after the '=' sign.

If there are different numbers AND you want to keep stuff after the numbers:
sed 's/=[0-9]*/=9999/'