lundi 12 juin 2017

bash if statement remove redundant lines

Is there a way to write the below without having to copy and paste the command multiple times?

success - it will print the "grep" to console and to the log file

failure - it will print the " console and to the log file as well

  if wget -S --spider ${proxystring}"$1" 2>&1 | grep 'HTTP/1.1 200 OK'; then
     wget -S --spider ${proxystring}"$1" 2>&1 | grep 'HTTP/1.1 200 OK' >> $LOGFILE
     return 0;
  else
      wget -S --spider ${proxystring}"$1" 2>&1 | $TEELOG
     return 1;
  fi

Aucun commentaire:

Enregistrer un commentaire