「head」と「tail」
UNIXシェルの「head」と「tail」を作成してみます。
「head」(読み込み行数のデフォルト:10)
function Get-Head { PARAM([String]$file, [int]$line=10) get-content $file | select-object -first $line } set-Alias head Get-Head
「head」利用例
MSH C:\..\Microsoft Command Shell>head about_Alias.help.txt 5 TOPIC Aliases SHORT DESCRIPTION Using pseudonyms to refer to Cmdlet names in the Microsoft Shell MSH C:\..\Microsoft Command Shell> head about_Alias.help.txt TOPIC Aliases SHORT DESCRIPTION Using pseudonyms to refer to Cmdlet names in the Microsoft Shell (MSH) LONG DESCRIPTION An alias is a pseudonym, or "nickname," that you can assign to a Cmdlet so that you can use the alias in place of the Cmdlet name.
「tail」(読み込み行数のデフォルト:10)
function Get-Tail { PARAM([String]$file, [int]$line=10) get-content $file | select-object -last $line } set-Alias tail get-tail
「tail」利用例
MSH C:\..\Microsoft Command Shell>tail about_Alias.help.txt 3 help lang_variable MSH C:\..\Microsoft Command Shell> tail about_Alias.help.txt help conc_profile.msh For information about functions, enter the following command: help lang_function For information about variables, enter the following command: help lang_variable