Search code examples
bashwildcardcuttail

Bash replace first 4 characters after tail -f


I have a log-file as .txt where I want the first four characters to be replaced by **** or XXXX to anonymize the data.

I am running the following command:

tail -f file.txt

I know I can cut the first characters the following way:

tail -f file.txt | cut -c4-

But I would then like to insert four wildcard characters.

How can I achieve this?


Solution

  • echo 1234567890 | sed 's/..../****/'
    

    Output:

    ****567890