echo "a b _c d _e f" | sed 's/[ ]*_[a-z]\+//g'
The result will be a b d f.
Now, how can I turn it around, and only print _c _e, while assuming nothing about the rest of the line?
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.
If the question is “How can I print only substrings that match specific a regular expression using
sed?” then it will be really hard to achieve (and not an obvious solution).grepcould be more helpful in that case. The-ooption prints each matching part on a separate line,-Penables PCRE regex syntax:And finally