Qual è l’equivalente del prompt di cmd di Windows per i comandi ‘head’ o ‘less’ di Linux?

Se puoi imparare a lasciare andare cmd e iniziare ad usare PowerShell (è stato incluso in Windows da quasi un decennio ormai; smettila di rimandare), puoi fare questo per un equivalente "head":

  1. type file.txt -Head 20 

and this for a “less” equivalent (first line is the long version; the second uses an alias and a common PowerShell shortcut technique for parameters):

  1. type file.txt | Out-Host -Paging 
  2. type file.txt | oh -p 

If you want to feel cool and Unix-y, you can use “cat” instead of “type”. Entrambi sono una scorciatoia per il comando PowerShell Get-Content.

Nota che questo non include la caratteristica principale di less rispetto a "more", che è la capacità di andare indietro attraverso le pagine di un file che hai già guardato. If you want that, you’re probably better off using a version of less compiled for Windows, which you can find here.

While I’m here, I might as well mention the PS equivalent of “tail”:

  1. type file.txt -Tail 20 

and “tail -f”:

  1. type file.txt -Tail 20 -Wait 

p.s. “head”, “tail” and “less” are GNU tools, not “Linux” commands per se. A machine running Linux is under no obligation to provide any of those commands.