title: how to store result of tail command in variable?
body: <p>I am developing application in MEAN stack. I want to create a script of image resizing &amp; cropping as a background process when new image uploads to server.</p>
  
  <p>Script watches new image uploads in folder and crop it.</p>
  
  <p>I preferred way of Linux shell scripting as daemon.</p>
  
  <p>I have used following idea to accomplished tasks.
     - New image uploads on server it writes in photolog.txt file, where I can grab images line by line.
     - I read photolog.txt in watch.sh shell scripting file.
     - It Iterates through line by line, until it reaches to the EOL.
     - Again new file arrives it will append at EOL.
     - I manage to get updated file by tail command, and get the latest add file display in command-line. Upto this code it works charm.</p>
  
  <p>Now I am successfully grab the image list of newly added file on server. but main issue is that I fails to store output of tail command in variable, and it must to me because whatever output I get it is full path of filename and it will use in imagemagick crop command.</p>
  
  <p><strong>Imagemagick center crop with scale an image.</strong></p>
  
  <blockquote>
    <p>convert -define <strong>file-type</strong>:size=<strong>widthxheight</strong> <strong>original_filename</strong> -thumbnail 120x120^ -gravity center -extent 100x100 <strong>resize_filename</strong></p>
  </blockquote>
  
  <p><strong>watch.sh</strong></p>
  
  <pre><code>#!/bin/bash
  path="/var/www/html/AppBite/trunk/photolog.txt"
  cat $path | \
  
  until false
  do
      # If file exists 
      if [[ -f "$path" ]]
      then    
          while IFS= read -r photo
          do
              imageFormat=`identify $photo | awk '{print $2}'`
              imageScale=`identify $photo | awk '{print $3}'`
              echo "$photo $imageFormat $imageScale"
          done
      fi
      # Continous monitor file changes via commandline
      tail -f $path
  done
  </code></pre>
  
  <p>I am successfully grab command-line output but I am not able to store value in variable, for next use imagemagick image processing command.</p>
  
  <p>or suggest me other way to continuous monitoring folder to get newly added file list.</p>