I'm trying to do this (just an example, not a real life situation):
$ mkdir test; ( cd test; echo "foo" > test.txt ); cat test.txt
cat: test.txt: No such file or directory
However, it fails, since cd test
directory change is reverted after subshell is finished. What is a workaround? I can't use script .sh
files, everything should be in one command line.