perl one liners + match word and delete string after separator

user58412

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
choroba

Just replace Password= at a beginning of a line followed by anything with the string Password=:

perl -i~ -pe 's/^Password=.*/Password=/' file

Update

To only replace the first occurence, add a flag:

perl -i~ -pe '$changed = s/^\s*Password=.*/Password=/ unless $changed;' file

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How to match parameter and replace the value after "=" separator

분류에서Dev

Delete lines x after a match

분류에서Dev

awk: Exact string match on field not working with NUL as record separator

분류에서Dev

How to delete one word forward in bash?

분류에서Dev

Match string beginning with ([*>@]|--) ending with one of these

분류에서Dev

Print the matched string in Perl pattern match

분류에서Dev

Match a specific number of characters in string and delete python

분류에서Dev

Microsoft Word 2016 - Footnote separator

분류에서Dev

Bot saying only one word in string

분류에서Dev

Print text that appears after a substring match using awk in Perl

분류에서Dev

iOS - appending string before and after the word

분류에서Dev

Make a pattern in lua that match one parenthese and string

분류에서Dev

regex to match first n lines after a specific word in Google Spreadsheet

분류에서Dev

After finding a word in html body, replace it with another one

분류에서Dev

Delete all files but one in a directory after running script

분류에서Dev

Remove One or More Blank Lines After a String

분류에서Dev

How to know if string contains more than one same word

분류에서Dev

Not able to insert image after the current one in word with microsoft.office.interop.word

분류에서Dev

Remove a numeric value along with the word after that numeric value in a String

분류에서Dev

Delete multiple lines if one line contains certain string in notepad++

분류에서Dev

How to use Perl one-liner to add line based on first line pattern match?

분류에서Dev

MS Access: how to delete everything in a string after two specific characters

분류에서Dev

One-Liners Script : (1) 한 줄과 다음 줄 삭제, (2) 파일의 값 변경

분류에서Dev

Regex to match end of the word

분류에서Dev

awk match whole word

분류에서Dev

Delete a word of attributedtext on textview

분류에서Dev

Replace SubString on Partial match of word

분류에서Dev

In Python, how might one replace a word within a string with a random item from a list?

분류에서Dev

Delete folders which not match a list

Related 관련 기사

  1. 1

    How to match parameter and replace the value after "=" separator

  2. 2

    Delete lines x after a match

  3. 3

    awk: Exact string match on field not working with NUL as record separator

  4. 4

    How to delete one word forward in bash?

  5. 5

    Match string beginning with ([*>@]|--) ending with one of these

  6. 6

    Print the matched string in Perl pattern match

  7. 7

    Match a specific number of characters in string and delete python

  8. 8

    Microsoft Word 2016 - Footnote separator

  9. 9

    Bot saying only one word in string

  10. 10

    Print text that appears after a substring match using awk in Perl

  11. 11

    iOS - appending string before and after the word

  12. 12

    Make a pattern in lua that match one parenthese and string

  13. 13

    regex to match first n lines after a specific word in Google Spreadsheet

  14. 14

    After finding a word in html body, replace it with another one

  15. 15

    Delete all files but one in a directory after running script

  16. 16

    Remove One or More Blank Lines After a String

  17. 17

    How to know if string contains more than one same word

  18. 18

    Not able to insert image after the current one in word with microsoft.office.interop.word

  19. 19

    Remove a numeric value along with the word after that numeric value in a String

  20. 20

    Delete multiple lines if one line contains certain string in notepad++

  21. 21

    How to use Perl one-liner to add line based on first line pattern match?

  22. 22

    MS Access: how to delete everything in a string after two specific characters

  23. 23

    One-Liners Script : (1) 한 줄과 다음 줄 삭제, (2) 파일의 값 변경

  24. 24

    Regex to match end of the word

  25. 25

    awk match whole word

  26. 26

    Delete a word of attributedtext on textview

  27. 27

    Replace SubString on Partial match of word

  28. 28

    In Python, how might one replace a word within a string with a random item from a list?

  29. 29

    Delete folders which not match a list

뜨겁다태그

보관