title: Linux shell script how to use the same output for second operation
body: <p>This script has been create to backup files 24 hours before from now (midnight crontab), but my concern is, while the first tar is being created (first find) a lot of "" files are being created, so when the second find is executed, it would remove more files than the first one, so the removed files would be more than the backed up.</p>
  
  <p><em><strong>Script edited on February 4th 2014, focus on loop for removing the listed files on temp file</em></strong></p>
  
  <pre><code>    #!/bin/sh
      DATE=`date '+%Y%m%d'`
      LOCATION=/home/see/rbirun/send/VPN/Mobile/
      FILE="cdr_backup_${DATE}.tar.gz"
      TEMPFILE="tempfile_${DATE}"
      ERROR="Error:Tar file not created nor removed the source call records"
      cd "${LOCATION}"
      find . -name 'VPN_CALLRECORD*' -type f -ctime 1 -print &gt; ${TEMPFILE}
      tar -czf ${FILE} -T ${TEMPFILE}
      if [ -f $FILE ];
      then
  
              number=$(more ${TEMPFILE} |wc -l)
              echo "$DATE:Number of files backed up--&gt;$number "&gt;&gt;log_after_cdr_backup.txt
              while IFS= read -r line
              do
                  rm -f $line
              done &lt; "${TEMPFILE}"
      else
              echo "$DATE:$ERROR"&gt;&gt;log_after_cdr_backup.txt
      fi             
  </code></pre>
  
  <p>Is there a way to ensure that the same source backed up is removed ? maybe using 'xargs' ?</p>
  
  <p>thanks in advance for your valuable help</p>