grepテスト

vccw内のMovefileからvhostの値を取り出すテスト。

[code]
grep "vhost:" ./Movefile | sed -e s/vhost://g | tr -d ‘\"\ ‘
[/code]

やってる内容は、

  • “vhost:”を含む行を抽出
  • “vhost:”を削除
  • ‘”‘, ‘ ‘を削除

っとすると、Movefileに設定されている、localのvhostと、productionのvhostと、その他にも-e(environment)を追加している場合はそれを取り出せる。

[code]
grep "vhost:" ./Movefile | sed -e s/vhost://g | tr -d ‘\"\ ‘ >> test.txt
cat test.txt
[/code]

で一応確認 😀

Movefile内のvhost部分を、vhost:とスペースと'”‘を取り除いて、そのn行目を取得

[code]
grep "vhost:" ./Movefile | sed -e s/vhost://g | tr -d ‘\"\ ‘ | sed -n 2p
[/code]