I tried searching the forum for this, and I read numerous suggestions here and even on other forums, and I cannot get this to want the way that I need it to. I tried grep -W / -f to no luck. Here is what I have. I have a list of file names-
I want to return only lines that contain FILE1-FILE1TEST exactly, not the other two hits, which for this test, I guess they can be considered, old data, or "versioned" data. here is what I have tried:
Another way to approach this would be awk, which understands the concepts of seperators and fields, so you can say "Print when field one matches this exact text", which seems to me a nicer way to write it but YMMV. Both work.
IMO you need to supply a suitable anchor for the pattern you are looking for in order to filter out lines that are similar but don't match your criteria...
Do you only want to find the string you're searching for at the start of a line? Or do you want to display a line if the string you're searching for appears at the end of a line?
Do all lines have two fields (as in your example)? Or, could some lines have only one field. Could some lines three or more fields?
grep on AIX does not have word boundary operator extensions (GNU,BSD) like \< , \> or \b , so they will not work.
It does however have the -w extension so I do not understand why
grep -w "FILE1-FILE1TEST" output.out
would not work.
Anyway, you could try this, which should work with any (POSIX compliant) grep: