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

  • Home
  • SEARCH
  • 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 3978760
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:05:14+00:00 2026-05-20T05:05:14+00:00

All is in the title : here is the string pattern of a multi-line

  • 0

All is in the title :

here is the string pattern of a multi-line file:

foo_bar_alpha = "a1b2c3_cat_andthis"  
barfoo_bar_alpha = "just a int number"  
loremfoo_bar_beta = "192.168.0.0"  
... other lines come here ...

Using sed (and/or awk and/or perl), I need to substitute char “_” with “.” , but only in the first part of the string, which is right delimited by “=”, and keep the 2nd part (after “=”).

Sthg like :

sed "s/(.*)=(.*)/ \1 with "_" replaced by "." = \2/g" < my_file
                   ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
                          how to do that ?

Thx in adv.

  • 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-20T05:05:14+00:00Added an answer on May 20, 2026 at 5:05 am
     awk '{gsub("_",".",$1)}1' ./infile
    

    Input

    $ cat ./infile
    foo_bar_alpha = "a1b2c3_cat_andthis"
    barfoo_bar_alpha = "just a int number"
    loremfoo_bar_beta = "192.168.0.0"
    

    Output

    $ awk '{gsub("_",".",$1)}1' ./infile
    foo.bar.alpha = "a1b2c3_cat_andthis"
    barfoo.bar.alpha = "just a int number"
    loremfoo.bar.beta = "192.168.0.0"
    

    *Note: If you for sure need to delimit on = because your variable names somehow contain spaces (highly doubtful) then this works:

    awk -F= '{gsub("_",".",$1)}1' OFS="=" ./infile
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm kinda stuck here. I have this pattern: <a class=title href=showthread.php?t=XXXXX id=thread_title_XXX>DATADATA</a> I know
I believe the title already says it all, but here is my question: what
Actually my question is all in the title. Anyway: I have a class and
Question title says it all really - a lot slower than VS2005, with a
The title should say it all, then I can solidify 2 more ticks on
The title pretty much says it all. Some caveats are: I need to be
The title pretty much says it all. I'm using a TClientDataset to store an
The title pretty much says it all. When I'm doing some reflection through my
Title more or less says it all. Specifically, I've become increasingly annoyed that in
How do I select all records that contain LCS within the title column in

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.