Hi Friends,
Following is an output of a script
OPWQERIUTYKLSADFJHGXZNMCVBWQOPERIUTYKLSADFJHGXZNMCVB
I want to replace above string's 11 to 17 character by ******* (7 stars)
How can it be done?
Please somebody guide me.
Hi Friends,
Following is an output of a script
OPWQERIUTYKLSADFJHGXZNMCVBWQOPERIUTYKLSADFJHGXZNMCVB
I want to replace above string's 11 to 17 character by ******* (7 stars)
How can it be done?
Please somebody guide me.
try:
echo -n `echo $str | cut -c 1-10` ; echo -n '*******' ; echo $str | cut -c 18-
You can use like this
$ a='OPWQERIUTYKLSADFJHGXZNMCVBWQOPERIUTYKLSADFJHGXZNMCVB'
$ echo $a | awk '{line=substr($0, 11,7);sub(line,"*******",$0);print $0; }'
great manoj!
And another way:
echo $a | sed 's/^\(.\{10\}\).\{7\}/\1*******/'
Thank you very very much Yogesh & Manoj.. both the suggestions are perfectly working.
Thank you once again
Bye & take care
echo OPWQERIUTYKLSADFJHGXZNMCVBWQOPERIUTYKLSADFJHGXZNMCVB |
sed 's/\(.\{1,10\}\)\(.\{1,7\}\)\(.*\)/\1*****\3/'> sed 's/\(.\{1,10\}\)\(.\{1,5\}\)\(.*\)/\1*****\3/'