2 ms·
I like using subshells for this: ( cd dir for f in ./*; [..] ) There's a few scenarios where this won't work (mainly if you want to set a vari
by arp242 3y ago
I like using subshells for this:
(
cd dir
for f in ./*; [..]
)
There's a few scenarios where this won't work (mainly if you want to set a variable from the "outer scope"), but 99% of the time it works nicely.
- bravetraveler 3y agoAh, that's a nice/neat thought - thank you for sharing! Makes total sense, temporary/disposable shell for such things