create a temp test file for testing your data
cat test.txt
hi this is my credit card number 1234567891234567
i have 22 this 22 is just for testing 1234567890123456 and this one
cat test.txt
hi this is my credit card number 1234567891234567
i have 22 this 22 is just for testing 1234567890123456 and this one
Here is the format which varies according to your requirement .
In my case there are 16 digits .
I want to mask first 6 number here is the regular expression or bash command
sed -e :a -e "s/[0-9]\{6\}\([0-9]\{10\}\)/\*\*\*\*\*\*\1/;ta" test.txt
here 6 and 10 are number of masks and number of visible characters respectively.
you can alter them according to your needs.
And the stars can be replaced by # or the value you want to mask with .
The number of starts should be equal to number of masks in my case it is 6
No comments:
Post a Comment