Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.