Question: How to pass large number of files as an argument for tar archive
creation?
Answer: Using the option ‘I’
From Solaris Man page:
-I include-file Opens include-file containing a list
of files, one per line, and treats
it as if each file
appeared separately on the command line. Be
careful of trailing white spaces. Also beware of leading
white spaces,
since, for each line in the included file, the entire line
(apart from
the newline) will be used to match against the initial string
of files
to include
SYNTAX: tar –cvf archive.tar -I filename
archive.tar -> your desired archive name
filename -> pass the file name which has list of files to
be archived
Example:
Listing the available files:
[st39422@dios8:/home/st39422]#ls -ltr
total 64
-rw-r--r-- 1 st39422
users 227 Aug 6 12:42 fileA
-rw-r--r-- 1 st39422
users 227 Aug 6 12:43 fileB
-rw-r--r-- 1 st39422
users 19 Aug 6 12:47
fileD
-rw-r--r-- 1 st39422
users 19 Aug 6 12:49
fileC
Putting filenames in a file and checking the content:
[st39422@dios8:/home/st39422]#cat > files_to_be_archived
fileA
fileB
fileC
fileD
[st39422@dios8:/home/st39422]#cat files_to_be_archived
fileA
fileB
fileC
filed
Creating a tar archive:
[st39422@dios8:/home/st39422]#tar -cvf multiple_files.tar -I
files_to_be_archived
a fileA 1K
a fileB 1K
a fileC 1K
a fileD 1K
Listing tar file contents:
[st39422@dios8:/home/st39422]#tar -tvf multiple_files.tar
tar: blocksize = 10
-rw-r--r-- 48153/63002 227 Aug 6 12:42 2012
fileA
-rw-r--r-- 48153/63002 227 Aug 6 12:43 2012
fileB
-rw-r--r-- 48153/63002 19 Aug 6 12:49
2012 fileC
-rw-r--r-- 48153/63002 19 Aug 6 12:47
2012 fileD
[st39422@dios8:/home/st39422]#
NOTE: Depending on the type and version of tar utility, option
needs to be used ( -I or –L eg: tar -cvf abc.tar -L jskfile or tar
-cvf xyz.tar -I jskfile )
No comments:
Post a Comment