¿Cuál es el equivalente en Windows a los comandos ‘head’ o ‘less’ de Linux?

Si puedes aprender a dejar de lado cmd y empezar a usar PowerShell (está incluido en Windows desde hace casi una década; deja de posponerlo), puedes hacer esto para 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”. Ambos son un atajo para el comando de PowerShell Get-Content.

Note que esto no incluye la característica principal de less en relación con "more", que es la capacidad de ir hacia atrás a través de las páginas de un archivo que ya ha mirado. 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.