I want to run a bash subshell, (1) run a few commands, (2) and then remain in that subshell to do as I please. I can do each of these individually:
Run command using
-c
flag:$> bash -c "ls; pwd; <other commands...>"
however, it immediately returns to the "super" shell after the commands are executed. I can also just run an interactive subshell:
Start new
bash
process:$> bash
and it won't exit the subshell until I say so explicitly... but I can't run any initial commands. The closest solution I've found is:
$> bash -c "ls; pwd; <other commands>; exec bash"
which works, but not the way I wanted to, as it runs the given commands in one subshell, and then opens a separate one for interaction.
I want to do this on a single line. Once I exit the subshell, I should return back to the regular "super"shell without incident. There must be a way~~
NB: What I am not asking...
- not asking where to get a hold of the bash man page
- not asking how to read initializing commands from a file... I know how to do this, it's not the solution I'm looking for
- not interested in using tmux or gnu screen
- not interested in giving context to this. I.e., the question is meant to be general, and not for any specific purpose
- if possible, I want to avoid using workarounds that sort of accomplish what I want, but in a "dirty" way. I just want to do this on a single line. In particular, I don't want to do something like
xterm -e 'ls'