Tuesday, November 27, 2018

grep match till the first occurence of a character



I am tying to grep from the below







I am trying:



$ echo ''| grep -o "]>"



I am getting the above. So how to get only



Answer



echo ''| grep -o "]*>"


Your .* is greedy, it matched the first > and beyond. My [^>]* is also greedy, but it cannot match anything that includes >, so > in the pattern matches the first occurrence of > in the input for sure.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...