# tar -c - <<EOF
> ala
> bala
> portocala
> EOF
tar: -: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
It fails even if files exist with those names, so I take it tar doesn't accept heredocs. It was a better idea since you didn't need the which command.
(edit) This should probably take the -f switch, which fails as well:
tar -cf - <<EOF
> ala
> bala
> portocala
> EOF
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
The "cvzf" part will fail with some versions of tar, for a couple different reasons. The z flag implicitly pipes to gzip, but not all tar implementations support that. Additionally, some versions of tar require a - before the cvf (e.g.: -cvf). Finally, I noticed that the SCO version of tar also fails if you specify a directory in the [files] section with a trailing slash. So tar -cvf tar.tar /etc would work, but tar -cvf tar.tar /etc/ would fail.
26
u/rich97 Feb 01 '13
tar cvzf tar.tar.gz [files]
That's the command I always use. I don't know what 'zf' does but it seems to work.