Logo 
Search:

Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

Scripts - how to cd and stay in that dir after the script ends

  Date: Dec 02    Category: Unix / Linux / Ubuntu    Views: 889
  

# 1.sh
echo
cd ~ # cd to home dir
ls # list the directory, proving what dir we are in
echo
./1.sh # trying to a run a script that is in the 'sh' dir
# the script cannot be found because we are not in that dir
exit 0
# after the script ends we are back in the 'sh'
# without actually changeing back to it in the script
# How do I stay in the dir I changed to in line 3?

Share: 

 

1 Answer Found

 
Answer #1    Answered On: Dec 02    

You can use the pushd and popd commands in bash - or if you don't like
bash, write your own equivalent functions in plain old bourne shell.

 




Tagged: