PowerShell_unix PowerShell is definitely gaining momentum in the windows scripting world but I still hear folks wanting to rely on unix based tools to get their job done.  In this series of posts I’m going to look at converting some of the more popular Unix based tools to PowerShell.


The Unix “nl” (number lines) command will take as input a list of files and, for each file, it will write the file to standard output with line numbers added.  There are a lot of options in the unix command and I’ve included the following:

Unix PowerShell Description
-b -numbering_style Use STYLE for numbering body lines
-i -increment Line number increment at each line
-n -number_format Insert line numbers according to FORMAT
-s -number_separator Add STRING after (possible) line number
-w -number_width Use NUMBER columns for line numbers

The values for the the numbering style (STYLE) are:

  • “a” – Number all lines.
  • “t” – Number only nonempty lines (default).
  • “n” – Number no lines.

And the values for the number format (FORMAT) are:

  • “ln” – Left justified, no leading zeros (default).
  • “rn” – Right justified, no leading zeros.
  • “rz” – Right justified, leading zeros.