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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -