简体   繁体   中英

Linux, how using tee in piped command

time curl http://www.google.com | tee | wc | gzip > google.gz

Why doesn't this command work? It creates the file, and times the operation, but does not print the number of lines, words, and characters (wc).

time curl http://www.google.com | tee | wc 

This will print print the words characters and lines, but obviously, the tee portion is pointless.

Is it because I'm sending the word count of the url to google.gz?

I have to use tee, gzip, time, curl to download google web page to a gziped file, print the word count, how long it took.

It is an assignment, so I'm not looking for someone to do it for me. I just am having a problem in that I can't tee to utility, and I cant to and gzip at the same time.

Maybe there is a way to use gzip with curl?

Well, wc outputs the number of characters, words and lines, but then you send it to gzip which compresses it. Eventually, compressed information ends up in google.gz . If you decompress the file, eg with

gunzip google.gz

you'll see the three numbers.

Also, normally when one uses tee , they specify a file where the tee'ed data is supposed to be stored.

time curl http://www.google.com | tee /dev/tty | gzip > google.gz

我将猜测您想要的是这样的东西:

time curl http://www.google.com | tee /tmp/z | gzip > google.gz; wc /tmp/z; rm /tmp/z

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM