I have added echo thisIsMyBash
at the end of my .bashrc
file. Now when I write create a new terminal with ctrl+alt+t
, thisIsMyBash is written a the beginning. This is as expected.
Now when I type /bin/bash
in my terminal thisIsMyBash is also displayed in my terminal.
But when I write /bin/bash -c "source ~/.bashrc"
in my terminal, nothing is written. Why?
Also when I actually write /bin/bash -c "source ~/.bashrc" && exec /bin/bash -li
thisIsMyBash also is displayed. Why that?
Any idea?
If you use the "-i" option of bash it will work as desired. This option make the shell interactive. Try this:
/bin/bash -i -c "source ~/.bashrc"
Take a look here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.