Because I can can never remember to use pigz I have to have this in my dotfiles: function ccm() { tar -cf - $1 | pigz > $1.tar.gz }
You wouldn't go outside without pants. You shouldn't use a variable without quotes. Put pants on all variables. Also, you shouldn't use () with 'function' it "works" in Bash but it's not standard:
ccm() {
tar c "${1}" | pigz > "${1}.tar.gz"
}
You could further improve it with a loop to accept multiple files: ccm() {
for i in $@; do
tar c "${i}" | pigz > "${i}.tar.gz"
done
}
Now you can run it like: `ccm file1 file2 file3`See: https://mywiki.wooledge.org/Quotes
See: https://mywiki.wooledge.org/BashGuide/CompoundCommands#Funct...