Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I address the standard filehandles (stdin and stdout) on the command line?

0
10 Posted

How can I address the standard filehandles (stdin and stdout) on the command line?

0
10

• A: You might need this to copy a part of your directory tree to another location using tar. Depending on the semantics, a single dash is interpreted as the respective standard channel. Example: $ tar cf – . | (cd somewhere_else; tar xvf -) Here we write everything in and below our current directory in tar format to the standard output which is connected to a nameless pipe, which in turn is connected to another tar which reads from stdin. “Depending on the semantics” means, if you tell tar to read, the dash is interpreted as stdin, whereas if you tell tar to write, the dash is interpreted as stdout. The parentheses are necessary to let the tar on the right side of the pipe access this pipe as the reader. Otherwise, cd would be the reader which is no very useful.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123