Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using SED/AWK to replace letters after a certain position

Tags:

sed

awk

I have a file with words (1 word per line). I need to censor all letters in the word, except the first five, with a *.

Ex.

Authority -> Autho****

I'm not very sure how to do this.

like image 458
Vijayraj S Avatar asked Dec 06 '25 14:12

Vijayraj S


1 Answers

If you are lucky, all you need is

sed 's/./*/6g' file

When I originally posted this, I believed this to be reasonably portable; but as per @ghoti's comment, it is not.

like image 81
tripleee Avatar answered Dec 08 '25 08:12

tripleee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!