Take the 2-minute tour ×

I work in at a telecom company and in some cases I need to search for multiple numbers around a specific time. I am using Ubuntu sever 10.04. When I search for a call my normal expression is:

grep 5555551234 20120719-12*

Where 20120719-12* is the date and time (GMT) for the number I am looking for.

When I use

grep 5555551234 20120719-18* | 5555551235 20120719-18*

I will only get a return on the first number

If I use

grep 5555551234 | 5555551235 20120719-18*

I receive -sh 5555551235 not found

Any feedback would be appreciated..

share|improve this question
add comment

migrated from stackoverflow.com Jul 22 '12 at 19:57

This question came from our site for professional and enthusiast programmers.

2 Answers

The pipe character (|) has special meaning to both grep and your shell. Use quoting to make sure the shell passes it to grep unmangled.

share|improve this answer
add comment

You will need to use regular expressions.

In your specific case you can use:

grep -E '(5555551234|5555551235) 20120719-18'


  • -E tells grep to use extended regular expressions
  • Don't forget the '
  • Do not put the * in the end of the expression

Just to clarify why you have that error: | is a pipe what basically means sh will redirect the output of the first application to the input of the second, in this case 5555551235, but sh can't find 5555551235, so the error.

share|improve this answer
add comment

Your Answer

