I've always either used cd - as @fluffy
pointed out or more often I used subshells (if I'm not mistaken about the name) which is simply used through parenthesis.
For instance: (cd /etc/mysql && exec ls)
but the one you have taught here is even cooler than the ones I've been using and I didn't know it. Thanks!
(cd /etc/mysql && exec ls)
Ah yeah subshells are great. I mostly use them to gather up the output from a bunch of commands but they’re also great for encapsulating environment. Note that you can also use ;s in them too!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.