Skip to content
Advertisement

How can I execute a command inside another folder and return to original directory?

I use this command to make inside a folder:

JavaScript

But I want to return to original directory after the command

I tried this:

JavaScript

But this doesn’t work. How can I do it? Would help in quick testing…

Advertisement

Answer

Use a subshell, like so:

JavaScript

The shell forks before running the commands in brackets, so once it completes it’s as if you never left the current directory.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement