As in, say I execute pwd to return the current directory and want to dump this in a script file so that I can come back, but I then need to prefix it with 'cd '?


I don't quite understand what you are asking here.

Maybe you could try something like this?

echo cd `pwd` > /tmp/file
  • I was messing around with awk & pipes. Doh. Thanks so much! – M. Tibbits Aug 20 '11 at 2:02

In case you're trying to accomplish this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.