Question on -l option in grep

Oracle Linux 6.3

I have 3 files a.sh , b.sh and c.sh

$ cat a.sh
hEllo world
NB_ORA_POLICY=Somestring1
Mumbo Jumbo
$
$ cat b.sh
stomper pumper
NB_ORA_POLICY=SomeString2
freeBird
$
$ cat c.sh
basketball is Good
NB_ORA_POLICY=SomeMoreString3
aquatic
$

The following grep command with -l option returns all files which has the string NB_ORA_POLICY .

$
$ grep NB_ORA_POLICY -l *.sh
a.sh
b.sh
c.sh
$

But, I want to print those lines with the string NB_ORA_POLICY from these files too. How can I do this?

why using -l ? just remove it and it will work as expected.

1 Like