比如说,我执行pwd
以返回当前目录,并希望将其转储到脚本文件中,以便我可以回来,但我需要在它前面加上“cd”前缀?
答案1
我不太明白你在这里问什么。
也许你可以尝试这样的事情?
echo cd `pwd` > /tmp/file
答案2
如果您想完成此任务:
cd -
# Changes directory to the last one you were in
或者
pushd and popd
# Push current directories on a stack with pushd
# Pop them back out (change to them) with popd