Logo 
Search:

Unix / Linux / Ubuntu Answers

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds
  on Nov 30 In Unix / Linux / Ubuntu Category.

  
Question Answered By: Adah Miller   on Nov 30

I am not aware of any clean way of doing what you want to do. Per the
bash documentation:

"A script can export variables only to child processes, that is, only to
commands or processes which that particular script initiates. A script
invoked from the command-line cannot export variables back to the
command-line environment. Child processes cannot export variables back
to the parent processes that spawned them."

You could write the $PWD of your script to a temp file (/tmp/whatever)
then cd to `cat /tmp/whatever` (note backward quotes which designate
"output of") when you exit.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Changing directories in a script Or get search suggestion and latest updates.


Tagged: