LoginSignup
2
0

More than 5 years have passed since last update.

シェルスクリプトでディレクトリ移動する

Posted at

職場のPCがwindows+cygwinで、vagrantのスクリプトがあるディレクトリに移動するのに難儀する。
階層が深すぎるのである・・・(Macがよかったなぁ・・・)
が、開発者みんな使ってるので、勝手にディレクトリ構成を変える訳にもいかない。
そしてcygwinってはじめて使ったけど、C:¥が/c/なのがどうもしっくりこなくて、打つの面倒。
ディレクトリ移動して起動するスクリプトを書いておいて、ちょいといつもとちがう感じで起動するすれば問題解決である。

sample_code/output/sample.sh

#!/bin/sh

echo "this is test!"
call.sh
#!/bin/sh

cd ./sample_code/output

./sample.sh

sample.shが起動したいスクリプトとする

$ . call.sh

のように叩くと

this is test!
$ pwd
/home/hoge/sample_code/output

実行後にスクリプト内でcdしたディレクトリに移っているのです。
面倒臭がりな私は、ディレクトリ移動して、vagrant resumeするのとsuspendのをスクリプトにしてます(それ位は入力しろよ・・・)

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0