I am trying to make a function that simply cd out of the working folder, and then moves that folder to somewhere else. However, when attempting this, I get a cannot move error, presumably because the folder is in use because that is where I launched the function.
e.g.
test() {
cpath=$(pwd)
cd ..
mv $cpath $cpath"old"
cd $cpath"old"
}
Is this even possible?
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
sourceit.