Jay
Jay

Reputation: 1

How do I find an ID in a file?

I have a text file called ID.txt that contains the following:

Here is a list of some ID's

b028888
c039481
b016396
c456039

Lets see if this stupid thing will work!

I am wanting to run a command that will search that file for the b-id's or c-id's. Any suggestions?

Upvotes: 0

Views: 584

Answers (2)

Memduh
Memduh

Reputation: 866

Try this;

$ grep "^[bc][0-9]\{6\}" filename

Upvotes: 0

Nishu Tayal
Nishu Tayal

Reputation: 20860

Lets say your data file is testdata.txt. You can use following commands to get IDs with b or c.

 sed -n '/^b/p' testdata.txt

 sed -n '/^c/p' testdata.txt

Upvotes: 1

Related Questions