searching pattern in tab delimited file using grep
Suppose i have a file(1.txt) separated by TAB delimiter in a line
1 B AB 2 2 C AB 2 if I need to search for the records having B?? using grep If i need to perform multiple search like line having "C and AB" or "B and AB"?? simple grep 'B' 1.text gives both record. Please help Thanks in advance Vaibhav |
Hi,
Use grep's -w option: grep -w B 1.txt -w -> Select only those lines containing matches that form whole words. Hope this helps. |
Hi,
What about 2nd question? If i need to perform multiple search like line having "C and AB" or "B and AB"?? Thanks, Vaibhav |
You can use a pipe to connect two grep commands.
|
Hi,
What do you actually want to search for: C<tab>AB or a C and AB anywhere in a line (AB X Y C would be an example of the second)? Assuming you want the first: grep "C<tab>AB" infile, there is one catch: pressing the tab will tell bash to try to complete the C. You can enter a tab in the search string by first pressing <ctrl-v> followed by pressing the <tab>. |
This is absolutely correct
Quote:
Thanks. It Worked! |
All times are GMT -5. The time now is 05:15 AM. |