File name: Test.sh
#!/bin/bash ZDir="$(echo /usr/src)" cd "$ZDir" When I execute the script ./Test.sh, the command cd doesn't do anything. If I try to do it directly in the bash terminal, it works like a charm. Also, echo, used inside and outside the script, returns me the correct value (/usr/src).
Does anyone know why this happens? Again: cd $ZDir works if used outside the script, directly in the terminal...
Edit: Could'nt find the answer on the "duplicate" one but that G-Man user right there answered exactly what i needed to do. Just included a && followed by the next command i needed to do and worked. Functions can also be used for this... cdZDir() { cd /usr/src; make; make install; }
Then just call in the function.