tar 引數列項目過長

回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

tar 引數列項目過長

文章 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
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: tar 引數列項目過長

文章 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
回覆文章

回到「Linux」