pattern matching question - grep
I am trying to grep for a pattern (as01dc intel Diff) in a file called "formatted.fle". The pattern in a variable called "input_record" which is read from a file.
I have attempted several methods but no success grep "$input_record" formatted_input.fle returns as01dc intel Diff 8251092 ias01dc intel Diff 96428 was01dc intel Diff 941104 The only valid one is the as01dc line So to isolate that I try grep - x "$input_record" formatted_input.fle it returns nothing grep "^as01dc intel Diff" formatted_input.fle retrurns as01dc intel Diff 8251092 which is OK but it needs to be a variable after that carat. grep "^$input_record" formatted_input.fle returns nothing I don't understand why the -x doesn't work. I don't understand how to use the carat. I am :study: but in 3 days I have not figured it out:scratch: |
Try using the -w option to have grep match on complete words: grep -w "$pattern" file
|
All times are GMT -5. The time now is 03:40 AM. |