How to extract tar archive from stdin?
Use -
as the input file:
cat largefile.tgz.aa largefile.tgz.ab | tar zxf -
Make sure you cat them in the same order they were split.
If you're using zsh you can use the multios feature and avoid invoking cat:
< largefile.tgz.aa < largefile.tgz.ab tar zxf -
Or if they are in alphabetical order:
<largefile.tgz.* | tar zxf -
How can I build a tar from stdin?
Something like:
tar cfz foo.tgz --files-from=-
But keep in mind that this won't work for all possible filenames; you should consider the --null
option and feed tar
from find -print0
. (The xargs
example won't quite work for large file lists because it will spawn multiple tar
commands.)
how to pipe contents of large tar.gz file to STDOUT?
Use this with GNU tar to extract a tgz to stdout:
tar -xOzf large.tar.gz --wildcards '*.html' | grep ...
-O, --to-stdout
: extract files to standard output
shell-scripting: Use a pipe as an input for tar
I don't see how "tar" figures into this at all; why not just compress the dump file itself?
pg_dump -U myUser myDB | gzip > myDB.sql.gz
Then, to restore:
gzip -cd myDB.sql.gz | pg_restore ...
The "tar" utility is for bundling up a bunch of files and directories into a single file (the name is a contraction of "tape archive"). In that respect, a "tar" file is kind-of like a "zip" file, except that "zip" always implies compression while "tar" does not.
Note finally that "gzip" is not "zip." The "gzip" utility just compresses; it doesn't make archives.
How would I tar extract pipe cd?
Pipes link up the output of one program to the input of another - just how a pipe sends the output from your garden tap (faucet) to your lawn sprinkler.
A minus sign (-) is a shortcut meaning either input or output - which one it means depends on position/context.
Your wget
command grabs some data from the web and, because of the -
, sends it through a pipe to tar
.
The tar
command reads that data from the pipe, because of its -
, and creates some files and directories.
The tar
command doesn't send anything down any further pipes, so there'd be nothing for cd
to read. You also don't know the name of the directory you want to go to. If you did, you could go there as a follow-up action like this:
wget ... - | tar ... - ; cd SOMEWHERE
Or you could make it conditional on the tar
command running successfully with:
wget ... - | tar ... - && cd SOMEWHERE
Linux Pipe viewer, how to split the pipe
Not sure that your original command works, as there are several errors in the options given to tar.
Given that ../MyFolder
exists, your first command need to be
pv large_file.tar.gz | tar -xz -C ../MyFolder
If you insert tee call between pv
and tar
calls, then the whole chain works.
pv large_file.tar.gz | tee /tmp/strout.log | tar -xz -C ../MyFolder
However i'm not sure it does what you expect. If you pipe pv output to tee, tee will pipe it to tar, and dump the same contents as the original tar to /tmp/strout.log, resulting in your tar extracted to ../MyFolder
and copied to /tmp/strout.log.
EDIT
As suggested by @DownloadPizza, you can use process substitution (see How do I write stderr to a file while using "tee" with a pipe?). By using -f
flag with pv, your command will become
pv -f large_file.tar.gz 2> >(tee /tmp/strout.log) > >(tar -xz -C ../MyFolder)
and will produce expected output.
Related Topics
Cannot Get Qwindow::Fromwinid to Work Properly
Deleting All Files Except Ones Mentioned in Config File
Data Pointers in Inode Data Structure
What Is The Mutex Acquire and Release Order
Trying to Install Docker Gpg Key Recieving Error: Curl: Option '-' Is Unknown
Wget Breaking with Content-Disposition
Merge Multiple Lines to 1 Row with Awk(Or Familiar)
Total Number of Bytes Read/Written by a Linux Process and Its Children
Skip Successfully Downloaded Files Using Wget
How to Handle Sigsegv Signal in Userspace Using Rust
Error While Running Parallel Make
Problems with Sudo Inside Expect Script
Gstreamer Video Output Position Tracking and Seeking
Where in The Linux Source Does Recognition of Specific Usb Devices Happen