title: Unable to untar a file?
body: <p>I have written a shellscript which tries to pull a tar file from an ftp server and untar it locally. I need to extract specific files from the tar archive. The filename of the tarfile contains a date; I need to be able to select a tar file based on this date.</p>
  
  <p><code>abc_myfile_$date.tar</code> is the format of the file I am pulling from the ftp server.</p>
  
  <p>My current code looks like this:</p>
  
  <pre><code>for host in ftpserver
  do
  ftp -inv host &lt;&lt;END_SCRIPT
  user username password
  prompt
  cd remotepath
  lcd localpath
  mget *myfile_$date*.tar
  quit
  END_SCRIPT
  done
  
  for next in `ls localpath/*.tar`
  do
  tar xvf $next *required_file_in_tar_file*.dat
  done
  </code></pre>
  
  <p>when i run the script am not able to untar the files</p>
  
  <p>I am able to get a single tar file from the ftp server only if I mention the exact name of that file. I would like to get a file which has <code>myfile_$date</code> in its name. After this I would like to extract it to a local path to get the specified files in that tar file whose names consist of my <code>required_files</code>.</p>