Let's say I want to execute several commands with similar flags such as:
du -sh / --exclude=/dir1 --exclude=/dir2 --exclude=/dir3/dir4
tar cvf archive / --exclude=dir1 --exclude=dir2 --exclude=dir3/dir4
I want to reuse the sequence of --exclude
flags and make the code more clean by e.g. saving these flags to a variable.
So afterwards above commands look like
du -sh / "$EFLAGS"
tar cvf archive / "$EFLAGS"
Note that tar
excludes files and directories relative to the given directory.
What is the best and cleanest solution?
Background
I want to backup my system using tar and exclude some directories that I don't need.
$IFS
- which is partly what quotes are designed to protect against. – mikeserv Jun 25 at 18:45