so want open new terminal in bash , execute command arguments. long take ls
command works fine, when take route -n
, command arguments, doesnt work. code:
gnome-terminal --window-with-profile=bash -e whoami
#works
gnome-terminal --window-with-profile=bash -e route -n
#doesnt work
i tried putting "" around command , still doesnt work
try this:
gnome-terminal --window-with-profile=bash -e 'bash -c "route -n; read"'
the final read
prevents window closing after execution of previous commands. close when press key.
if want experience headaches, can try more quote nesting:
gnome-terminal --window-with-profile=bash \ -e 'bash -c "route -n; read -p '"'press key...'"'"'
(in following examples there no final read
. let’s suppose fixed in profile.)
if want print empty line , enjoy multi-level escaping too:
gnome-terminal --window-with-profile=bash \ -e 'bash -c "printf \\\\n; route -n"'
the same, quoting style:
gnome-terminal --window-with-profile=bash \ -e 'bash -c '\''printf "\n"; route -n'\'
variables expanded in double quotes, not single quotes, if want them expanded need ensure outermost quotes double:
command='printf "\n"; route -n' gnome-terminal --window-with-profile=bash \ -e "bash -c '$command'"
quoting can become complex. when need more advanced simple couple of commands, advisable write independent shell script readable, parametrized code need, save somewhere, /home/user/bin/mycommand
, , invoke
gnome-terminal --window-with-profile=bash -e /home/user/bin/mycommand
Comments
Post a Comment