Tar archiving that takes input from a list of files

前端 未结 6 2028
[愿得一人]
[愿得一人] 2020-12-22 17:12

I have a file that contain list of files I want to archive with tar. Let\'s call it mylist.txt

It contains:

file1.txt
file2.txt
...
file         


        
相关标签:
6条回答
  • 2020-12-22 17:25

    You can also pipe in the file names which might be useful:

    find /path/to/files -name \*.txt | tar -cvf allfiles.tar -T -
    
    0 讨论(0)
  • 2020-12-22 17:40

    Yes:

    tar -cvf allfiles.tar -T mylist.txt
    
    0 讨论(0)
  • 2020-12-22 17:45

    On Solaris, you can use the option -I to read the filenames that you would normally state on the command line from a file. In contrast to the command line, this can create tar archives with hundreds of thousands of files (just did that).

    So the example would read

    tar -cvf allfiles.tar -I mylist.txt
    
    0 讨论(0)
  • 2020-12-22 17:45

    For me on AIX, it worked as follows:

    tar -L List.txt -cvf BKP.tar
    
    0 讨论(0)
  • 2020-12-22 17:49

    Some versions of tar, for example, the default versions on HP-UX (I tested 11.11 and 11.31), do not include a command line option to specify a file list, so a decent work-around is to do this:

    tar cvf allfiles.tar $(cat mylist.txt)
    
    0 讨论(0)
  • 2020-12-22 17:52

    Assuming GNU tar (as this is Linux), the -T or --files-from option is what you want.

    0 讨论(0)
提交回复
热议问题