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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:46:35+00:00 2026-06-15T06:46:35+00:00

I have a string variable $LIBRARIES=abc.so.1 def.so.1 hij.so.3.1 and I want to replace all

  • 0

I have a string variable $LIBRARIES="abc.so.1 def.so.1 hij.so.3.1" and I want to replace all the .so such that they look like this:

"abc.so* def.so* hij.so*" 

How can I do this? I tried NEW_LIBRARIES=${LIBRARIES//.so*/.so$star} but it doesn’t work. How can I tell it to end on whitespace?

  • 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-06-15T06:46:37+00:00Added an answer on June 15, 2026 at 6:46 am

    This should do it:

    LIBRARIES="abc.so.1 def.so.1 hij.so.3.1"
    NEW_ALL_LIBRARIES=$(sed 's/\.so[^ ]*/\.so\*/g' <<< "$LIBRARIES")
    echo "$NEW_ALL_LIBRARIES"
    

    Output:

    abc.so* def.so* hij.so*
    

    Explanation:

    • LIBRARIES="...": When assigning a string to a variable, the variable is not prefixed with $
    • NEW_ALL_LIBRARIES=$(...): The $(...) notation is called command subsitution; basically it spawns a new subshell to run whatever commands contained within, then returns the output to this new subshell’s stdout (and here saving it to NEW_ALL_LIBRARIES).
    • sed: invoke sed, the Streaming EDitor tool
    • 's/\.so[^ ]*/\.so\*/g': Use regular expressions (regex) to match patterns and substitute. Let’s break this syntax down a bit further:
      • s/ “substitute”; For example: s/A/B/g replaces all occurrences of A with B
      • \.so[^ ]*/: Match any patterns that start with .so, and the [^ ]* part means “followed by zero or more non-space characters”
      • \.so\*/: Replace that with literally .so*
      • Some symbols such as [, ], . and * have special meaning in regex, so if you mean to use them literally, you just “escape” them by prefixing a \
      • g: Do so for all occurrences, not just the first.
    • <<< "$LIBRARIES": the <<< notation is called herestring: in this context it accomplishes the same thing as echo "$LIBRARIES" | sed ..., but it saves a subshell.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string variable in C# aka product_name, I want to filter like
I have javascript string variable with var sttr=We prefer questions that can be answered
I have a String variable say strHTML = <div class='abc'> This is a test
I want to have a string variable for a PHP class, which would be
i have a long string variable and i want to search in it for
I have a string variable that represents the name of a custom class. Example:
I have a string variable that contains an HTML page's response. It contains hundreds
I have String variable called jsonString : {"phonetype":"N95","cat":"WP"} Now I want to convert it
I have a string variable containing time in hh:mm:ss format . How to convert
I have a String variable (basically an English sentence with an unspecified number of

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.