#navi(../)
* PowerShellでtouchファンクションを作ってみた [#ae603f06]
LinuxなどUNIXコマンドのtouchコマンドをPowerShellでtouchファンクションを作ってみました。~
以下にサンプルスクリプトを記します。
#contents
#htmlinsertpcsp(win-top.html,win-sp.html)
* 関連記事 [#t64efd39]
-[[PowerShellでuptimeファンクションを作ってみた>PowerShell/PowerShellでuptimeファンクションを作ってみた]]
* touchファンクション [#e8478acd]
**サンプルスクリプト [#qe757b3b]
touchのサンプルスクリプトになります。
Function touch($file) {
If (Test-Path $file) {
(Get-Item $file).LastWriteTime = Get-Date
} Else {
Out-File -encoding Default $file
}
}
** 実行結果 [#e782ffe4]
touchによる空ファイル作成とファイルの日時変更のスクリーンショットです。
*** touchファンクションによる空ファイルの作成 [#w2b49404]
#ref(01.png)
#br
*** touchファンクションによるファイル書き込み日時の変更 [#jf88dda2]
#ref(02.png)
#br
以上、PowerShellでtouchファンクションを作ってみたでした。
#htmlinsertpcsp(win-btm.html,win-sp.html)