For searching odt documents I used the command

for f in *.odt; do echo $f; odt2txt "$f" | grep -i "Слово поиска"; done 

As expected, when outputting grep, it highlighted the search phrase (light red bold). Today decided to transfer it to the script

 #!/usr/bin/sh for f in *.odt do echo $f odt2txt "$f" | grep -i "$1" done 

It still works, but for some reason the search phrase is not highlighted (everything is displayed in standard font), as in the case of a single command from the console. Why, and how to return the backlight?

    1 answer 1

    add option --color with value always

     $ grep --color=always ... 

    details in man grep .


    in the first case described, it is likely that the program is not called grep directly, but an alias with additional options (for example, about the same color). you can check it like this:

     $ alias grep 
    • Thanks $ alias grep alias grep = 'grep --color = auto' - Yuchimenko Igor