I work with linux/solaris machines and I need to add some rule in my ksh script:
Please advise how to match the password word in file, and delete the value password after the separator "=" with perl liner command
second it will delete only the first password!
For example
more file ( before delete the password )
Password fkwf324ei23
Password=fkwf324ei23
Pass_word=fevme
Secret_Password=vrev873662j
Password=fkwf324ei23
.
more file ( after delete the password )
Password fkwf324ei23
Password=
Pass_word=fevme
Secret_Password=vrev873662j
Password=fkwf324ei23
Just replace Password= at a beginning of a line followed by anything with the string Password=
:
perl -i~ -pe 's/^Password=.*/Password=/' file
To only replace the first occurence, add a flag:
perl -i~ -pe '$changed = s/^\s*Password=.*/Password=/ unless $changed;' file
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다