Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

grep for multiple information

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...
0
brothertom
Asked:
brothertom
  • 3
  • 2
1 Solution
 
Maciej SsysadminCommented:
For example: egrep "UTC|00:02:6f" file
0
 
upanwarCommented:
# egrep -i "UTC|00:02:6f" file
0
 
brothertomAuthor Commented:
Many thanks.

Incidentally, what is the difference between grep and egrep?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
upanwarCommented:
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
0
 
Maciej SsysadminCommented:
You can of course use "grep -e" instead of egrep. Or even "grep -E". Check "man grep" for differences.
0
 
upanwarCommented:
yeah thats true but grep -e dont work on Solaris, It works on HP-UX,AIX and Linux.

http://www.experts-exchange.com/OS/Unix/Q_26961760.html
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now