用dd跳过stdin的前32k?

nwa*_*ham 6 bash stdout dd

如果我在文件系统上有一个文件,我可以用 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 命令

dev*_*ull 5

你可以使用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)

  • 哦,多么丑陋的语义。为了跳过 1024 字节,给出 `+1024` 会更合乎逻辑。但是不,他们选择了其他方式:-( (2认同)