We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

grep for multiple information

Medium Priority
507 Views
Last Modified: 2013-12-26
I want to grep a file for lines containing the following text in one pass:
UTC  or 00:02:6f

Is it possible to create a grep expression to do this, so I end up with the following (the UTC line is a header timestamp in the data set)
...UTC...
...00:02:6f...
...UTC...
...00:02:6f...
...UTC...
...00:02:6f...
Comment
Watch Question

sysadmin
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
# egrep -i "UTC|00:02:6f" file

Author

Commented:
Many thanks.

Incidentally, what is the difference between grep and egrep?

Commented:
egrep: Search a file for a pattern using full regular expressions.

Example: egrep "support|help|windows" myfile.txt

http://www.computerhope.com/unix/uegrep.htm

grep: Finds text within a file.

grep "unix" myfile.txt

http://www.computerhope.com/unix/ugrep.htm
Maciej Ssysadmin
CERTIFIED EXPERT

Commented:
You can of course use "grep -e" instead of egrep. Or even "grep -E". Check "man grep" for differences.

Commented:
yeah thats true but grep -e dont work on Solaris, It works on HP-UX,AIX and Linux.

https://www.experts-exchange.com/OS/Unix/Q_26961760.html
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.