Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6960167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:22:02+00:00 2026-05-27T15:22:02+00:00

I analysed logs with http://www.w3perl.com/ , now i want the IPs made anonymous. So

  • 0

I analysed logs with http://www.w3perl.com/, now i want the IPs made anonymous.

So i want them changed in all html-files in the whole directory.

  1. I thought about just always turning the third and fourth octet into the same number for all IPs. But i read something about XOR-ing them – what is that about?

  2. what is the better way to manage the replacing and why? sed or perl or another option?

I am pretty new to this, i hope i searched the other topics enough. I haven’t found anything related to my problem.
Thanks in advance and please excuse my English.
This website is just great – i’ve learned so much in the last days!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:22:03+00:00Added an answer on May 27, 2026 at 3:22 pm

    Masking IP-Address can be better achieved with perl. You can take a look here for using already available modules so that you won’t have to re-invent the wheel. Unfortunately I don’t know perl, so I can only offer sed solution.

    You can use something like this for replacing all ip-address in your file.

    sed 's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/**masked ip**/g' < yourfile > newfile
    

    Your file:

    [jaypal:~/Temp] cat fmp
    this is 12.34.55.222 and 
    21.3.34.5
    also there is 133.42.55.23
    

    Step 1: Identify IP-Addresses:

    [jaypal:~/Temp] sed 's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/**&**/g' fmp
    this is **12.34.55.222** and 
    **21.3.34.5**
    also there is **133.42.55.23**
    

    Step 2: Replace IP-Address with your mask

    [jaypal:~/Temp] sed 's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/**&**/g' fmp | sed '/\*\*.*\\*\*/s//**masked ip**/'
    this is **masked ip** and 
    **masked ip**
    also there is **masked ip**
    

    You can either make sed -i (in-line) substitution or use > to re-direct your output to another file.


    Obviously this can be reduced to the following. The above would be useful for debugging as you can view what is being changed before making the change.

    [jaypal:~/Temp] sed 's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/** masked ip **/g' fmp
    this is ** masked ip ** and 
    ** masked ip **
    also there is ** masked ip **
    

    Good Luck!!

    Update:

    As posted by Mark in the comments, a perl variant would be –

    perl -pe 's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/** masked ip **/g' < inputfile > outputfile
    

    Update II:

    As requested by OP, the following one-liner will find the files and perform the substitution.

    find /path/to/dir/ -type f -name "*.html" -exec perl -ibak -pe 's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/** masked ip **/g' {} \;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why is the editable html moved into an iFrame? I analysed different editors (TinyMce,
Today at a customer we analysed the logs of the previous weeks and we
At the moment I have ResultsCollection = List<MyDataStructure>; which is then analysed with LINQ
i dont want to do something illegal with it(e.g. vote continuously, in fact, somebody
I am trying to integrate NHibernate.Search into a multi-lingual website. Now, this website contains
How do I repair malformed HTML using C#? A great answer would be an
How do I enable the MySQL function that logs each SQL query statement received
I have analysed a dataset of GPS points using density.ppp to generate a sort
I have this code which I have analysed in Firebug and it is really
Yes, I know that my problem is not the unique, but I have analysed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.