Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a content of file test

>-----------------max------------------

>-----------------abc

def

<------------------mnc------------------

jkl

Here I want to grep the line that contains < > symbol

I tried this method

[max@localhost ~]$ grep \> \< test

grep: <: No such file or directory

test:>-----------------max------------------

test:>-----------------abc

but it's not working what should i do now?

share|improve this question
1  
You considered that the input for grep looks like this: grep PATTERN FILE FILE FILE FILE ...? – Bobby Oct 15 '12 at 12:00
    
@Bobby PATTERN is this only > < i know these are redirect symbol, but how to remove the special meaning of this symbol, i thought that putting slash in front of this symbol remove the special meaning, but i am wrong in this case – max Oct 15 '12 at 12:13
up vote 2 down vote accepted

could do like this:

grep -e ">" -e "<" test
share|improve this answer
    
it's working... Thanks – max Oct 15 '12 at 12:30

Always try to use single quotes with grep:

grep '>\|<' test

The above example also makes use of the OR (|) operator.

You might also want to match these symbols only at the beginning of the line, in which case you'd want to do this:

grep '^(>\|<)' test

( ( ) make a group, ^ signifies the beginning of the line )

share|improve this answer
    
grep '>\|<' test This is working for me... Thanks – max Oct 15 '12 at 12:32

From the man page:

The symbols \< and > respectively match the empty string at the beginning and end of a word.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .