Hi All,
I have one file with below type of data in it,
$ cat test.txt
###123
###xyxytuerwb
###2
###tyupe
Here I would like to replace all the characters with "x" after the 3 "###" with the same number of characters.
Can you please help me to achieve this.
can you post the output you are expecting?
After masking output will look like below,
###xxx
###xxxxxxxxxx
###x
###xxxxx
awk -F# '{gsub(".","x",$NF)}1' OFS=# file
1 Like
Hi Franklin,
Thanks a lot it worked perfectly.
One more thing can these "###" retained ?
panyam
6
A sed version
sed '/^###/ s/./x/g' -e 's/^xxx/###/g' input_file
Through tr
tr '[a-z0-9]' 'X' < inputfile
If you have GNU sed
sed 's/./X/4g' inputfile
ctsgnb
8
sed '/^###/s/[^#]/x/g' infile
$ cat tst
###123
blabslbla
###xyxytuerwb
###2
blabla
###tyupe
$ sed '/^###/s/[^#]/x/g' tst
###xxx
blabslbla
###xxxxxxxxxx
###x
blabla
###xxxxx