0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

コマンドラインで場所を変えずに他のディレクトリからファイルを実行する方法

Posted at

下記のディレクトリ構造で、dir1にいる状態で、dir2からコマンドを実行したい時があり、調べたところ簡単に実行できることがわかった。

├── dir1
│   └── dir2

上記のdir1にいる状態で、dir2からコマンドを実行する場合。


user@MacBook-Pro dir1 % (cd dir2 && pwd)
/dir1/dir2
user@MacBook-Pro dir1 % pwd
/dir1

上記のようにコマンドに()をつけると、コマンド実行後もdir1のままでいられる。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?