When tar-ing up large directories (ie. a home folder for a backup/OS reinstall), it is often okay to exclude certain large files such as multi-GB videos. However, due to the all-encompassing nature of a home folder, it is often unrealistic to remember each and every file that may be useful to exclude (with --exclude) before starting. I am looking for some sort of input that I can give to tar to tell it to quit whatever file it's on and move onto the next, leaving the quitt-ed file out of the archive. Perhaps like a control-C, but instead of stopping the entire process, simply stop the current file.Specifically, I am referring to a long running tar -cvf or tar -cvzf. As both of these commands contain -v it is easy to determine what file tar is currently on. Using any sort of GUI tool is not an option, as tar is often run in a minimal (CLI only) environment on a broken system before a reinstall. This is the specific case I am asking about.
Remove Specific File From Tar Archival Process After the Process Starts
ubuntu;command line;tar
I don't think that is possible, but you might simply just exclude largefiles automatically from your tar. For example,find mydir ! -type f -o \( -type f -size -1000k \) | tar cv --no-recursion -T - -f /tmp/tar which does not save files bigger than 1000k.Here's a script to ask interactively for a n reply to stop big filesbeing archived:find mydir \( -type f -size +1000k -exec /tmp/biggie {} \; \) -o -print |tar c --no-recursion -T - -f /tmp/tarwhere /tmp/biggie is the script#!/bin/bashif ! read -t 10 -n 1 -p $1 ok ? reply || [ n != $reply ]then echo >&2     echo $1else echo  ignoring $1 >&2fiwhich does a bash-specific read with timeout of 10 seconds of 1 char (-n),with the filename as prompt (-p). If you type n within 10 secondsthe file is ignored.