Yunad
Yunad

Reputation: 11

What is the mystery behind tar with (- -m) parameter?

I am trying to understand why certain part of code does not work.

tar xzf - -m'

that is what makes an issue. I have tried various combinations, but without understading what does it do (excluding tar xzf itself) I cannot fix it. I also do not know if '- -m' the first - is some kind of error... (Command itself is a part of bigger script, script itself is a part of a pipeline.)

tar: Refusing to read archive contents from terminal (missing -f option?)
tar: Error is not recoverable: exiting now

That is the error I get.

Upvotes: 1

Views: 759

Answers (1)

Nikos C.
Nikos C.

Reputation: 51920

f takes an argument, and that argument is the filename of the archive. If instead of a filename you use -, it means tar should read data not from a file, but from standard input. However, since in this case the standard input is the terminal, tar refuses to work.

To redirect standard input to a file, you'd use:

tar xzf - < archive.tar

The '-m' option just instructs tar to not extract the "file modification time" of the files it extracts from the archive.

Upvotes: 2

Related Questions