2018年11月17日 星期六

[Linux 常見問題] bash: /bin/tar: Argument list too long when compressing many files with tar

Source From Here 
Question 
I am trying compress files from an archive with the command 
# tar -czvf compress_file.tar.gz $(cat file_list.txt)

And I have an error 
-bash: /bin/tar: Argument list too long

The files numbers is too long, how can I resolve this? 

How-To 
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

If you find yourself stuck with over 30,000 files in a directory (text files in this example), packing them into a tar file can be tricky. You can get around it with this: 
// -print True; print the full file name on the standard output, followed by a newline. 
# find . -name '*.txt' -print >/tmp/test.manifest 

// -T, --files-from=FILE 
// get names to extract or create from FILE
 
# tar -cvzf textfiles.tar.gz --files-from /tmp/test.manifest 

# find . -name '*.txt' | xargs rm -v


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...