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 6255059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:17:41+00:00 2026-05-24T14:17:41+00:00

I have a file with : STRING.STRING2.STRING3 = VALUE1 bla bla text bla bla

  • 0

I have a file with :

STRING.STRING2.STRING3            = VALUE1 bla bla text bla bla

And i want to obtain something like this:

<string name="STRING.STRING2.STRING3">VALUE1 bla bla text bla bla</string>

using only shell commands like grep or sed and others

until now i reached to that:

TEMP=`cat $file |
        sed '/^\#/d' $file       
        sed 's@=@">@'                
        sed 's@\.@_@g'               
        sed 's:(\\s){3}::g'`                

echo "$TEMP " | sed 's@^@<string name="@'  |
        sed 's@$@</string>@'

(also the 5th doesnt work too well…)

  • 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-24T14:17:42+00:00Added an answer on May 24, 2026 at 2:17 pm

    If you use bash, can be done completely in the shell:

    str="STRING.STRING2.STRING3            = VALUE1 bla bla text bla bla"
    shopt -s extglob
    IFS="+( )=+( )"
    read v1 v2 <<< "$str"
    printf '<string name="%s">%s</string>\n' "$v1" "$v2"
    

    produces

    <string name="STRING.STRING2.STRING3">VALUE1 bla bla text bla bla</string>
    

    Edit: to process a file

    shopt -s extglob
    while IFS="+( )=+( )" read v1 v2; do 
      printf '<string name="%s">%s</string>\n' "$v1" "$v2"
    done < filename
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string)
I have a file values.txt with hierarchical formatting like this: group1 subgroup1 value1 value2
I have a .txt file looking like this: 1 Some string Some other string
I have this: Dim myTemp As String myTemp = System.DateTime.Now().ToString(MMMddyyyy_HHmmss) & .pdf System.IO.File.Copy(myFile, c:\
In my spring application context file, I have something like: <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String"
When I try to pass a string to a function like so i=file:///bla/bla/bla; Fade(i);
Suppose you have a text file like: my_setting = ON some_method = METHOD_A verbosity
I have a ini file which contains some sample values like: [Section1] Value1 =
I have an XML configuration file with a collection of strings like so: <SomeSetting>value</SomeSetting>
I have a C# application that includes the following code: string file = relativePath.txt;

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.