Ubuntu – How does -a command line option in grep work?

command linegrep

I am trying to learn to use the grep command.

I am not able to access the -a option and understand how it works.

Best Answer

  • By default, grep will show if a binary file matches the pattern, but will not show the matched lines; would simply say e.g.:

    Binary file /filename matches
    

    But when you use -a, grep would show the matched portions, not the above message.

    Here is a task for you:

    grep bash /bin/bash
    grep -a bash /bin/bash