1 頁 (共 1 頁)

tar 引數列項目過長

發表於 : 2015-05-02 21:41:21
yehlu
http://datoumao.blogspot.tw/2012/05/tar ... -long.html

原因:檔案太多,超過shell規定的數量


解決方法:
1.tar -rf
step 1.touch SEND
step 2.tar -cf abc.tar SEND
step 3.find . ! -name . -prune -name "*.AN3" -exec tar -rf abc.tar {} \;


2.tar -cf
step 1.find . -name "*.AN3" | grep -v bak > AN3.lst
step 2.tar -cf abc.tar -L AN3.lst

http://www.unix.com/unix-for-dummies-qu ... files.html

I'm guessing you're on AIX -- I've run into this problem on numerous occasions. The tar command should have a "-I include-file" option which lists file names one per line. Of course, you'll hit the same argument limit with ls, so populate the file with find....


Code:

代碼: 選擇全部

# find . -type f -name "*.bas" > include-file
# tar -I include-file -cvf newfile.tar

代碼: 選擇全部

$ find . -name ‘*.html’ -print > ./allfiles
$ tar -cf allhtml.tgz –files-from ./allfiles
Or, you can move the lot into a subdirectory ./bas and just tar that.


Code:

代碼: 選擇全部

# tar -cvf newfile.tar bas

Re: tar 引數列項目過長

發表於 : 2015-05-02 21:43:26
yehlu
http://stackoverflow.com/questions/2381 ... s-with-tar

Use the "-T" option to pass a file to tar that contains the filenames to tar up.

代碼: 選擇全部

tar -cv -T file_list.txt -f tarball.tar