PowerShell(備忘録3) ― 2011/03/26 07:10
PowerShellでオブジェクトのメンバー関数を取得する。
DirectoryInfo | Get-ChildItem | Get-Member
Cドライブのカレントから読み込み
${c:test.txt}
フルパスを指定して読み込み
${C:\data\test.txt}
PowerShell - ビットごとの論理演算子 (band, bor, bxor) を使用するには
http://itnandemolab.blog70.fc2.com/blog-entry-196.html
Foreach-Object の使い方(全てのプロセスで使用しているメモリ量の取得)
(Get-Process | Foreach-Objet{$sum=0}{$sum+=$_.WS}{$sum}/1GB
偶数の取り出し方
1..20 | Where-Object{ !($_ -band 1) }
引数の区切り文字を,とする場合
function foo{ $ofs=","$args}
foo abc def と入力すると、abc,defと表示される。
便利なユーティリティ関数
function ql{ $args }
function qs{ "$args" }
スイッチの作り方
function goo( [switch]$please ){ if($please){ スイッチ指定された場合} }
関数をパイプラインで使う方法($inputで受ける)
function foo{ $sum=0; foreach($n in $input){ $sum+=$n } $sum; }
1..10 | foo
関数をパイプラインで受ける方法 その2
function foo( $p ){ $sum=0; while( $input.MoveNext() ){ $sum += $input.current.$p } $p; }
フィルタの種類
匿名フィルタ:1..10 | Foreach-Object{ $_ * 2 }
名前付きフィルタ: 1..10 | filter double{ $_ * 2 }
foo 関数の内容を見る。書き換えも可能。
$function:foo
$function:foo={"GOOD"}
被災地の現実 ― 2011/03/26 10:51
支援物資調達に被災者がお金を用意しなくてはならない現実
http://www.news-postseven.com/archives/20110320_15335.html
被災地での“火事場泥棒” 住民は仕方がないと目をつぶった
http://www.news-postseven.com/archives/20110324_15716.html
被災者の行政相談ダイヤルを開設 東日本大震災で総務省
http://www.hokkaido-np.co.jp/news/topic/280538.html
未曾有の国難というなら、副次的な被災まで国が全力でバックアップすべき
http://news.livedoor.com/article/detail/5440825/
KxOxUxMxExI's Tumblr(原発ジプシーについて)
最近のコメント