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 ..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
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:
/dev/bit you asked for (I won’t say “for clarity”)\(...\)bit matches a subgroup, here sdc2 or whatever, so we can refer to it in the replacement[^[ ]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)gflag at the end tells it to perform multiple matches per line, instead of stopping at the first one