linux - In 'grep' - Why does it behave this way? -


file still contains:

a b c d 

and

grep -v -e "a" -e "d" still 

gives:

b c 

which expected.

now, file fill contains:

a,b,c,d 

my command

grep -v -e "a" -e "d" fill 

i expected give me ,b,c,. but, no output. why ?

first of all, first example should give :

b c 

not

b d 

because have -v

your 2nd attempt gave nothing, because grep match line-wise. if whole line doesn't match, line won't in output.

if want remove a , d in 2nd example, use sed:

kent$  echo "a,b,c,d"|sed 's/[ad]//g' ,b,c, 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -