bash - Unexpected behavior of 'grep' -


can please explain behavior of grep below case:

$ grep <html> foo $ bash: html: no such file or directory 

you need escape < , > inside bash.

  • use backslash escape single character
  • use single quotes escape multiple characters

correct syntax:

grep '<html>' myfile grep \<html\> myfile 

further information:

< , > used i/o redirection. < accepts input , > redirects output. thus, grep <html> foo tries read file named html , redirects output file myfile.


Comments

Popular posts from this blog

java - Callback from new thread to class from which thread was initiated -

Receive udp packets in android gstreamer -

php - Extract Text from HTTP referer -