I have a file of form
foo.txt
id, some_string, stringy_string..
and so on
How do I find a particular id in this foo.txt
This id will/should be present in just one line. (i.e no multiple instances?)
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on how the id’s look like. If they do not contain any grep special characters, you can use
The
^matches the beginning of the line, the comma just makes sure the id ends there (soid12is not matched inid123).You have to escape special characters if they can appear in the id.