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.

How can I grep for lines of a file wich start with a certain string?

For example, all lines with prefex 0x, where the file has the lines

0x002
0x003
abc

Output should be

0x002
0x003
share|improve this question

migrated from stackoverflow.com Apr 29 '13 at 17:11

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

1 Answer 1

up vote 9 down vote accepted
grep '^0x'

^ means the starting of a line

e.g.

kent$  echo "0x002
0x003
abc
"|grep '^0x'
0x002
0x003
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.