tar
cannot write to standard output on Ubuntu 16:
prod ~ $ cat /etc/os-release | grep -i version
VERSION="16.04.2 LTS (Xenial Xerus)"
VERSION_ID="16.04"
VERSION_CODENAME=xenial
prod ~ $ tar -cf - tmp
tar: Refusing to write archive contents to terminal (missing -f option?)
tar: Error is not recoverable: exiting now
Let's try on CentOS7:
[root@drft068 ~]# tar -cf - /tmp
tar: Removing leading `/' from member names
tar: /tmp/mongodb-27018.sock: socket ignored
tar: /tmp/mongodb-27017.sock: socket ignored
tmp/00017770000000000000000000000000131574472010
What do I do wrong?
tar -cf - tmp | cat
tar
noticed that itsstdout
is connected to a terminal, thus refused to clutter it with its binary output.cat
has no provisions for this. Redirectingtar
's output tocat
thus connects the former'sstdout
to something not a terminal andcat
doesn't care.tar
has been patched to do so and CentOS' version hasn't. I'm not sure if this is included in upstreamtar
versions or if it's an Ubuntu specific patch. In the former case, compare the versions of thetar
you're using. Maybe it's not even GNUtar
...