enthuguy
asked on
Mask property values using bash and sed
Hi Experts,
pls refer this question. would like to extend bit further on masking the pwd values when we have more than one properties in a file.
https://www.experts-exchan ge.com/que stions/291 07089/Disp lay-file-c ontent-but -mask-pass word-value -in-bash.h tml
Solution from above question
could you pls help me how to mask two properties in single go please
hostname=server1
db_sid=oracledb
db_username=scott
db_passowrd=tiger
username_wls=weblogic
password_wls=welcome1
target_script_dir=/u01/app /oracle/sc ripts
target_db_client_home=/u01 /app/oracl e/db/clien t_1
pls refer this question. would like to extend bit further on masking the pwd values when we have more than one properties in a file.
https://www.experts-exchan
Solution from above question
cat /path/to/property//file|sed -e 's/db_password=.*/db_password=xxxxxxxxx/i'
could you pls help me how to mask two properties in single go please
hostname=server1
db_sid=oracledb
db_username=scott
db_passowrd=tiger
username_wls=weblogic
password_wls=welcome1
target_script_dir=/u01/app
target_db_client_home=/u01
I assume db_passowrd=tiger should be db_password=tiger. Is that correct?
ASKER
Sorry typo
Yes, you are correct :)
Yes, you are correct :)
Why would you use cat to redundantly pipe to sed? That line can be changed to remove the extraneous cat command.
sed -e 's/db_password=.*/db_passw ord=xxxxxx xxx/i' /path/to/property//file
You can chain multiple cammands in sed.
sed -e 's/db_password=.*/db_passw ord=xxxxxx xxx/i' -e 's/password_wls=.*/passwor d_wls=xxxx xxxxx/i' /path/to/property//file
sed -e 's/db_password=.*/db_passw
You can chain multiple cammands in sed.
sed -e 's/db_password=.*/db_passw
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"Close Request Pending
enthuguy requested that this question be closed on 7/16/2018, as follows:
enthuguy's comment #a42620693 (0 points)
For the following reason:
Thanks very much
To cancel this request, state your reason as a comment and click the 'Object' button."
I object to the above closure attempt, since it doesn't make much sense to be thanking experts while assigning points to one's own comment which wasn't even an answer. I'm guessing this was a mistake.
You can chain multiple cammands in sed.
sed -e 's/db_password=.*/db_passw ord=xxxxxx xxx/i' -e 's/password_wls=.*/passwor d_wls=xxxx xxxxx/i' /path/to/property//file
True, serialband, and you can also do it without any '-e' switches like this:
sed 's/db_password=.*/db_passw ord=xxxxxx xxx/i; s/password_wls=.*/password _wls=xxxxx xxxx/i' /path/to/property//file
enthuguy requested that this question be closed on 7/16/2018, as follows:
enthuguy's comment #a42620693 (0 points)
For the following reason:
Thanks very much
To cancel this request, state your reason as a comment and click the 'Object' button."
I object to the above closure attempt, since it doesn't make much sense to be thanking experts while assigning points to one's own comment which wasn't even an answer. I'm guessing this was a mistake.
You can chain multiple cammands in sed.
sed -e 's/db_password=.*/db_passw
True, serialband, and you can also do it without any '-e' switches like this:
sed 's/db_password=.*/db_passw