bashと正規表現
ログインしたときに、screenが起動していたらアタッチ、起動していなかったらscreenを実行するスクリプトを.bash_profileに書いてみたのだけど、どうもスマートじゃない。
tmp=2 ps aux | grep ^odawara | grep screen$ &> /dev/null tmp=$? echo $tmp if [ $tmp -eq 0 ]; then screen -x elif [ $tmp -eq 1 ]; then screen else echo "else" fi
とりあえず、想定通りの動きにはなる…、が、正規表現がよくわかってないからgrepを2つパイプしてるし、ifの分岐の取り方もなんか変。いいやり方ないですかね?