我无法接通SED。一旦我将输出通过管道传输到SED,就不能将SED的输出通过管道传输到其他地方。
wget -r -nv http://127.0.0.1:3000/test.html
输出:
2010-03-12 04:41:48 URL:http://127.0.0.1:3000/test.html [99/99] -> "127.0.0.1:3000/test.html" [1]
2010-03-12 04:41:48 URL:http://127.0.0.1:3000/robots.txt [83/83] -> "127.0.0.1:3000/robots.txt" [1]
2010-03-12 04:41:48 URL:http://127.0.0.1:3000/shop [22818/22818] -> "127.0.0.1:3000/shop.29" [1]
我通过sed传输输出以获得一个清晰的URL列表:
wget -r -nv http://127.0.0.1:3000/test.html 2>&1 | grep --line-buffered -v ERROR | sed 's/^.*URL:\([^ ]*\).*/\1/g'
输出:
http://127.0.0.1:3000/test.html
http://127.0.0.1:3000/robots.txt
http://127.0.0.1:3000/shop
然后我想将输出转储到文件,所以我这样做:
wget -r -nv http://127.0.0.1:3000/test.html 2>&1 | grep --line-buffered -v ERROR | sed 's/^.*URL:\([^ ]*\).*/\1/g' > /tmp/DUMP_FILE
我在几秒钟后中断进程并检查文件,但它是空的。
有趣的是,以下内容不会产生任何输出(与上面相同,但通过cat传输sed输出):
wget -r -nv http://127.0.0.1:3000/test.html 2>&1 | grep --line-buffered -v ERROR | sed 's/^.*URL:\([^ ]*\).*/\1/g' | cat
为什么我不能将SED的输出通过管道传输到另一个程序,比如cat?