title: Convert shell script to one liner by escaping necessary thing?
body: <p>How to convert a shell script in one-liner by escaping everything? For example: replace end of lines by \n and double the other backslashes and other necessary things.</p>
  
  <pre><code>#!/bin/bash
  
  HOSTNAME=$hostname
  DATA=""
  RETRY=50
  
  echo $HOSTNAME
  
  sleep 1m
  
  while true; do
  
  while [ $RETRY -gt 0 ]
  do
      DATA=$(wget -O - -q -t 1 http://$HOSTNAME:8080/process)
      if [ $? -eq 0 ]
      then
          break
      else
          if lsof -Pi :8080 -sTCP:LISTEN -t &gt;/dev/null ;
          then
              echo "Server is already running"
          else
              echo "Server is not running so starting it"
              /opt/abc/hello start
          fi
          let RETRY-=1
          sleep 30
      fi
  done
  
  if [ $RETRY -eq 0 ]
  then
      echo "Server is still down. Exiting out of shell script." &gt;&amp;2
      exit 2
  fi
  
  echo "Server is up. Now parsing the process."
  #grep $DATA for state
  state=$(grep -oP 'state: \K\S+' &lt;&lt;&lt; "$DATA")
  [[ -z "$state" ]] &amp;&amp; state=0
  
  echo "$state"
  
  #validate the conditions
  if [[ "$state" == "DONE" || "$state" == "0" ]]; then exit 0; fi
  
  #wait another 30 seconds
  sleep 30
  
  done
  </code></pre>
  
  <p>Is there any way to convert above script in one-liner either using Python or Linux by escaping all the necessary things?</p>