Question

I'm new to linux/aix. I'm working on aix and i have the following problem:

if i try a

find . -type f -exec fgrep -l 'searchword *$'

doesn't return nothing or is stuck.

I know that i have files with the searchword.

Does fgrep -l doesn't suport the *$?

To give a better explanation, i`m searching some logs on my computer for a 'searchword' which in front of it can have anything but i want it to finish with *word, and than grep that line. Also i now that the line after *word has spaces or blank, thats why i put *$.

Was it helpful?

Solution

You will need {} to complete your fgrep and you don't need wildcard in grep pattern:

 find . -type f -exec fgrep -l 'searchword' '{}' \;

Also note that you don;t really need find since modern grep support recursive search also.

Something like would also work:

grep -lr 'searchword' *

OTHER TIPS

fgrep is used primarily for searching for fixed strings rather than regular expressions.

Just use grep or egrep, both of which cater for regular expressions.

In addition, you need to provide the file marker and terminator to the -exec flag:

find . -type f -exec grep -l 'searchword *$' {} ';'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top