Exclude particular files from strings output

Hi everyone,

Is it possible to have the command strings exclude particular files?

Here is what I am currently writing:

strings *20161212*

It prints all files in the directory, which is good, but some file types do not need to be printed because they contain gibberish. I am trying the below to exclude all the files with a .out extension, but it does not work:

 strings *20161212 ! '*.out'

Any ideas?

Please, test the following:

find . -path './*' -prune -type f -name '*20161212*' ! -name '*.out' -exec strings {} +
1 Like

Hi Aia,

Thanks! That works well. I am not familiar with find, how would you add a grep in there?

Pipe it?

find . -path './*' -prune -type f -name '*20161212*' ! -name '*.out' -exec strings {} + | grep something
1 Like

Excellent, thanks again Aia, this is very helpful.

In recent shells,

(cf man bash ).
Try

shopt -s extglob
strings *20161212!(*.out)

You may have to adapt the pattern, and YMMV.