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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:26:31+00:00 2026-05-26T13:26:31+00:00

please provide me a sed oneliner which provides this output: sdc3 sdc2 for Input

  • 0

please provide me a sed oneliner which provides this output:
sdc3 sdc2
for Input :
sdc3[1] sdc2[0]

I mean remove all subscript value from the string ..

  • 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-26T13:26:32+00:00Added an answer on May 26, 2026 at 1:26 pm
    sed 's/\[[^]]*\]//g'
    

    reads: substitute any string with literal “[” followed by zero or more characters that aren’t a “]”, and then the closing “]”, with an empty string.

    You need the [^]] bit to prevent greedy matching treating “[1] sdc2[0]” as a single match in your sample string.


    As for your comment:

    sed 's#\([^[ ]*\)\[[^]]*\]#/dev/\1#g'
    
    • I switch the seperator from the usual ‘/’ to ‘#’, just to avoid escaping the /dev/ bit you asked for (I won’t say “for clarity”)
    • the \(...\) bit matches a subgroup, here sdc2 or whatever, so we can refer to it in the replacement
    • the subgroup uses a similar character class to the one we used discarding the index: [^[ ] means any character except an “[” (again, to avoid greedily matching the index) or a space (assuming your values are space-delimited as per your post)
    • the replacement is now the literal “/dev/” followed by the first (and only) subgroup match
    • the g flag at the end tells it to perform multiple matches per line, instead of stopping at the first one
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could anyone please provide XPath expression which selects all nodes that have explicit 'xmlns'
Please provide me any link or application which provides payment functionality on iPhone... for
If this is possible, please provide a sample query or two so I can
Please provide pointers to help me mock that java InputStream object. This is the
please provide me link of good open source exe which i can call from
Please provide me guidance for wifi voice chat. I have gone through all the
Please provide me the proper solution of this script with explanation: $a = 5;
Can anyone please provide me with a sample code for this? I have a
I have the following code skeleton try { ... ... sysout(Please provide an input:
How to return by reference using function.Please provide me with complete funcion definition which

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.