For example, let's say I have a directory called tmp and I am on the home directory
$pwd
/my/home/directory/
$ls
tmpdir
and I have a tmp.sh that cds into the "tmp" directory
#!/bin/bash
cd tmp
and I run the script using:
$sh tmp.sh
after running this script, I am still in my home directory.
1) I want to understand why this doesn't work thoroughly(I just roughly know it has to do with children process that is independent of parent process(is this even right?))
and
2) how can I go about accomplishing this task(being end up in the directory that a script cd-ed in upon the completion of execution of the script)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…