Skip to main content
don't use brackets when testing return codes, the [ is a test operator that returns a return code anyway
Source Link
Caleb
  • 72k
  • 19
  • 203
  • 232

Your problem(s) are in this line:

if `cat $htmlFile | grep -inE "\<br\>"` ; then

It's telling the shell to:

  • cat a file,
  • parse it and look for lines that match the <br> tag,
  • execute the output

The problem is the last step, you shouldn't execute the output of the command but test it:

if [ grep -inEq "\<br\>" $htmlFile ] ; then

Of course, to parse HTML you should use a real parser, no regexes.

Your problem(s) are in this line:

if `cat $htmlFile | grep -inE "\<br\>"` ; then

It's telling the shell to:

  • cat a file,
  • parse it and look for lines that match the <br> tag,
  • execute the output

The problem is the last step, you shouldn't execute the output of the command but test it:

if [ grep -inEq "\<br\>" $htmlFile ] ; then

Of course, to parse HTML you should use a real parser, no regexes.

Your problem(s) are in this line:

if `cat $htmlFile | grep -inE "\<br\>"` ; then

It's telling the shell to:

  • cat a file,
  • parse it and look for lines that match the <br> tag,
  • execute the output

The problem is the last step, you shouldn't execute the output of the command but test it:

if grep -inEq "\<br\>" $htmlFile ; then

Of course, to parse HTML you should use a real parser, no regexes.

deleted 2 characters in body
Source Link
Braiam
  • 36.9k
  • 29
  • 114
  • 176

Your problem(s) are in this line:

if `cat $htmlFile | grep -inE "\<br\>"` ; then

It's telling the shell to:

  • cat a file,
  • parse it and look for lines that match the <br> tag,
  • execute the output

The problem is the last step, you shouldn't execute the output of the command but test it:

if [ -n grep -inEinEq "\<br\>" $htmlFile ] ; then

Of course, to parse HTML you should use a real parser, no regexes.

Your problem(s) are in this line:

if `cat $htmlFile | grep -inE "\<br\>"` ; then

It's telling the shell to:

  • cat a file,
  • parse it and look for lines that match the <br> tag,
  • execute the output

The problem is the last step, you shouldn't execute the output of the command but test it:

if [ -n grep -inE "\<br\>" $htmlFile ] ; then

Of course, to parse HTML you should use a real parser, no regexes.

Your problem(s) are in this line:

if `cat $htmlFile | grep -inE "\<br\>"` ; then

It's telling the shell to:

  • cat a file,
  • parse it and look for lines that match the <br> tag,
  • execute the output

The problem is the last step, you shouldn't execute the output of the command but test it:

if [ grep -inEq "\<br\>" $htmlFile ] ; then

Of course, to parse HTML you should use a real parser, no regexes.

Source Link
Braiam
  • 36.9k
  • 29
  • 114
  • 176

Your problem(s) are in this line:

if `cat $htmlFile | grep -inE "\<br\>"` ; then

It's telling the shell to:

  • cat a file,
  • parse it and look for lines that match the <br> tag,
  • execute the output

The problem is the last step, you shouldn't execute the output of the command but test it:

if [ -n grep -inE "\<br\>" $htmlFile ] ; then

Of course, to parse HTML you should use a real parser, no regexes.