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" }
这甚至可能吗?
The problem is that you're changing the directory in a different process. From your script you cannot touch the environment of the parent, unless you source it.
source