Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
作業フォルダからCDを取り出して、そのフォルダを別の場所に移動する関数を作成しようとしています。ただし、これを実行しようとすると、移動できないというエラーが発生します。これは、関数を起動した場所であるため、フォルダーが使用されているためと考えられます。
例えば
test() { cpath=$(pwd) cd .. mv $cpath $cpath"old" cd $cpath"old" }
これも可能ですか?
問題は、別のプロセスでディレクトリを変更していることです。スクリプトからは、親の環境に触れることはできませんsource。
source