如果我在文件系统上有一个文件,我可以用 dd 做这样的事情:
dd if=/my/filewithaheader.bin bs=32k skip=1 | gunzip | tar tvf
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试这样的事情:
./commandthatputsstuffonstdout | dd bs=32k skip=1 | gunzip | tar tvf
Run Code Online (Sandbox Code Playgroud)
我收到错误:
dd: 'standard input': cannot skip to specified offset。
我该如何解决这个问题,可以用 dd 来完成,还是有另一个我可以使用的 unix 命令
你可以使用tail. 说:
./commandthatputsstuffonstdout | tail -c +1025 ...
Run Code Online (Sandbox Code Playgroud)
跳过1024命令产生的输出的第一个字节。
来自man tail:
-c, --bytes=K
output the last K bytes; alternatively, use -c +K to output
bytes starting with the Kth of each file
Run Code Online (Sandbox Code Playgroud)