Created
January 20, 2022 01:58
-
-
Save tackme31/e2b2a136b17ce23a4b8c43725060b383 to your computer and use it in GitHub Desktop.
A PowerShell commandlet like bash's 'nl' command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Join-LineNumbers { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$True, | |
ValueFromPipeline=$True)] | |
[string[]]$Lines | |
) | |
begin { | |
$private:i = 1 | |
} | |
process { | |
foreach ($line in $Lines) { | |
Write-Output "$private:i`t$line" | |
$private:i++ | |
} | |
} | |
} | |
Set-Alias -Name nl -Value Join-LineNumbers -Option None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment