2 ms·
Okay, I feel that my first response was too snarky. I'm sorry. In its place, I'll say: You wouldn't go outside without pants. You shouldn't use a variable with
by mmh0000 3y ago
Okay, I feel that my first response was too snarky. I'm sorry. In its place, I'll say:
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 https://mywiki.wooledge.org/Quotes
See: https://mywiki.wooledge.org/BashGuide/CompoundCommands#Functions https://mywiki.wooledge.org/BashGuide/CompoundCommands#Funct...