Extra space generated in search

Hello,

When I issue this command:

Write-Output "abc", "def" | grep abc

I get:

 abc

(Note the extra spavce before abc)

When I issue this command:

Write-Output "abc", "def" | grep  -v abc

I get:

def

The grep command is from Git Bash, the -v means exclude.

When grep matches the first line, a leading space is generated before the “abc”.

But very strangely, this command:

Write-Output "abc", "def" | grep abc | Format-Hex

Does not show any space…!



           00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000   61 62 63                                         abc

Any clue what could cause the extra space when searchinf for “abc” ?

Thanks.

Are you asking “why the extra spaces in the hex output”? Because that’s how it normally outputs.

I do not get an extra space in front of abc.

PS /home/doug> Write-Output "abc","def" | grep -v abc
def
PS /home/doug> Write-Output "abc","def" | grep abc
abc