Curl

如何使用curl查看很長輸出的頂部?

  • May 15, 2021

我曾經curl從某個伺服器訪問 ASCII 資訊,但它總是移動到底部。我如何確保它從頂部開始?

關於cat命令有一個類似的問題,我想解決方案可能是將輸出重定向到文件,然後less按照此處的建議使用。有沒有可能更有效?

less您可以使用標誌通過管道輸出+Gg(檢查評論):

curl ... | less +Gg

來自手冊頁的標誌的含義:

   g or < or ESC-<
          Go to line N in the file, default 1 (beginning of file).  (Warn‐
          ing: this may be slow if N is large.)

   G or > or ESC->
          Go to line N in the file, default the end of the  file.   (Warn‐
          ing:  this  may  be slow if N is large, or if N is not specified
          and standard input, rather than a file, is being read.)

引用自:https://unix.stackexchange.com/questions/649840