ablog

不器用で落着きのない技術者のメモ

2010-01-13から1日間の記事一覧

xargs でコマンドに引数をひとつずつ渡す方法

# ls /dev/sd[a-z][0-9]* | xargs -n1 tune2fs -l | egrep 'Maximum mount count|Check interval' Maximum mount count: -1 Check interval: 0 (<none>) tune2fs: Bad magic number in super-block while trying to open /dev/sda2 Couldn't find valid filesystem</none>…

bash で ファイルのタイムスタンプを比較する

$ ls -l -rw-r--r-- 1 oracle oinstall 0 1月 13 18:45 a -rw-r--r-- 1 oracle oinstall 0 1月 13 18:46 b $ if [[ a -ne b ]]; then > echo a is newer than b. > else > echo a is older than b. > fi a is older than b. 参考 http://www.geocities.jp/ge…

bash でループの中でループの外のシェル変数の値を変更する

$ a=1 $ ls|while read LINE > do > a=2 > done $ echo $a 1 と、ループの中で変数 a の値を変更してもループの外の変数 a の値は変わらない。 forやwhile文などのリダイレクト処理はカレントシェルではなく、 サブシェルで実行される http://lagendra.s.kan…