Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
how can i grep a specific string ???
i want to grep something like this <whatIwant> i want this only So
grep -o "\<*\>" file > tofile Didn't work
grep -o "<*>" file > tofile Didn't work also
i want to grep just words between this '<' and this '>' symbols
neither this nor that worked ..
i just want string between something like
<anything> to be grepd not the whole line
when just i say grep "<this>" fromfile > tofile
then i have tofile contain somthing like that
those examples didn't do so at all
Post up a couple-three lines of the actual text you want to parse and then the result you'd want from those lines.
Based on your description, either of our solutions do work (and homey's sed is way better ), so we must not be following your description. Or maybe you're using a weird shell or weird versions of commands.
-- Here's a copy'n'paste from my xterm:
1016>> cat testfile
testing <this thing> out
testing this thing out
testing <that thing> out
1017>> sed -n 's/\(.*\)\(<.*>\)\(.*\)/\2/p' testfile > results
1018>> cat results
-- edit2 -- are you using the brackets as examples or are they actually what you want to parse? And do you want them actually in the results or not? That may be part of it.
<this mean > , <the meaning>, this mean <the meaning>, this Mean <the meaning>, but this mean <the meaning>, and this mean <the meaning>, not like this <the meaning>, even this , don't like any of this this mean <the meaning>, this mean <the meaning>, "this mean "<the meaning>, Mine Iz Like this <the meaning>, NOT @ All ,this mean <the meaning>,