Avatar of aggunia
aggunia
Flag for United States of America

asked on 

How do I tar files in a directory using an input file?

I have flat file containg relative file names in a given directory on a Unix box.  I'd like to be able to tar up all these files using a loop that reads the file list.  I have tried this but only get the last file name in the tar:

myFile="$HOME/Cleanup_Files.before"
myLine=""
while [ 1 ]; do
  read myLine || break
  tar -cvf cleanup_backup_files.tar $myLine
done < $myFile

Could someone let me know what I'm doing wrong?  Like I said...I only have the last file in the .tar...not all the files in the list.  Thanks!
Shell Scripting

Avatar of undefined
Last Comment
aggunia

8/22/2022 - Mon