Link to home
Start Free TrialLog in
Avatar of madan1278
madan1278Flag for Singapore

asked on

replace text

The below command would replace pwdwarntime = 0 to  pwdwarntime = 14
cat /etc/security/user | sed "127,200s/pwdwarntime = 0/pwdwarntime = 14/"

But I require to replace pwdwarntime = XX to pwdwarntime = 14

XX mean any value.

Thanks in advance
SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madan1278

ASKER

Thankyou very much.
I have another question for which I have increased the points further up by 75

cat passwd

root:
     password = gCwSI.DOGx7Jg
     some text here

daemon:
      password = jsfdsf.24343444
      some text here

madan:
        password = 1V5dvL8cAjTSk
        some text here

I need to change password = * only for the ID daemon. Is it possible.

Thanks
I hope you're not posting real passwords in a public forum
its just a test machine. shdnt be  a problem.
Avatar of Tintin
Tintin

Why are you updating the passwords manually?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is AIX's format.  Naturally, they do everything a little bit different.  I'd still like to know what madan1278 is *really* trying to do.  This sledgehammer approach can't be the best way.  It's always dangerous to manually manipulate passwords.
well, I wont claim any expertise in AIX, but I jumped on one:

# uname -a
AIX <edited to save my job> 3 4 000179194C00

# head -1 /etc/passwd
root:!:0:0::/:/bin/ksh

looks "normal" to me. maybe 3.4 is an old version, and IBM has "improved" it! lol
/etc/passwd is pretty much the same, but AIX uses a whole series of files under /etc/security to hold the shadow information, plus a whole lot more.
ah, thanks. ... thus your concern on manual edits, it's all making sense! :)
LINE=`grep -nw "${user}:" /etc/security/passwd| awk -F: '{print $1}'`
PASS=`expr $LINE + 1`
cat /etc/security/passwd | sed "${PASS}s/password = .*/password = */" > /tmp/passwd
mv /tmp/passwd /etc/security/passwd

I follwed the above method. But the comments from dtkerns were useful. As said I will split my points to ozo & dtkerns

Thanks for all ur help.