Results 1 to 6 of 6

Thread: [bash] Grep strange behaviour

Threaded View

  1. #1
    Join Date
    Oct 2011
    Beans
    41

    [bash] Grep strange behaviour

    I was 'grep'ping a text file:
    Code:
    vvss@vvss-laptop:~/tmp $ cat abc.txt 
    abc pqr
    abcpqr
    pqr abc
    a pqr
    ab cpqr
    grep behaves strangely if I add the --color=always option parsed to grep -v. Following are the outputs of the three different option of --color and also without grep -v parsing:

    Code:
     vvss@vvss-laptop:~/tmp $ grep -r abc abc.txt | grep -v abcpqr
    abc pqr
    pqr abc
    Code:
     vvss@vvss-laptop:~/tmp $ grep -r --color=auto abc abc.txt | grep -v abcpqr
    abc pqr
    pqr abc
    Code:
    vvss@vvss-laptop:~/tmp $ grep -r --color=never abc abc.txt | grep -v abcpqr
    abc pqr
    pqr abc
    Code:
    vvss@vvss-laptop:~/tmp $ grep -r --color=always abc abc.txt | grep -v abcpqr
    abc pqr
    abcpqr
    pqr abc
    Code:
     vvss@vvss-laptop:~/tmp $ grep -r abc abc.txt | grep -v abcpqr
    abc pqr
    pqr abc
    What happens if you give --color=always option? Why does it ignore the grep -v parsing?

    Thanks in advance

    VInay
    Last edited by vinay_wagh; June 18th, 2013 at 07:45 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •