Archivo Tar que toma entrada de una lista de archivos
Tengo un archivo que contiene una lista de archivos que quiero archivar con tar.
Vamos a llamarlo mylist.txt
Contiene:
file1.txt
file2.txt
...
file10.txt
¿Hay alguna forma en que pueda emitir el comando TAR que tome mylist.txt
como entrada?
Algo así como
tar -cvf allfiles.tar -[someoption?] mylist.txt
Para que sea similar a si emito este comando:
tar -cvf allfiles.tar file1.txt file2.txt file10.txt
6 answers
Sí:
tar -cvf allfiles.tar -T mylist.txt
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-11-07 07:48:38
Asumiendo GNU tar (ya que esto es Linux), la opción -T
o --files-from
es lo que quieres.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-11-07 07:47:45
También puede canalizar los nombres de los archivos que podrían ser útiles:
find /path/to/files -name \*.txt | tar -cvf allfiles.tar -T -
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-29 05:46:16
Algunas versiones de tar, por ejemplo, las versiones predeterminadas de HP-UX (probé 11.11 y 11.31), no incluyen una opción de línea de comandos para especificar una lista de archivos, por lo que un trabajo decente es hacer esto:
tar cvf allfiles.tar $(cat mylist.txt)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-15 19:10:55
En Solaris, puede usar la opción-I para leer los nombres de archivo que normalmente indicaría en la línea de comandos desde un archivo. En contraste con la línea de comandos, esto puede crear archivos tar con cientos de miles de archivos (sólo lo hizo).
Así que el ejemplo sería
tar -cvf allfiles.tar -I mylist.txt
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-25 20:18:31
Para mí en AIX, funcionó de la siguiente manera:
tar -L List.txt -cvf BKP.tar
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-20 19:06:45