How to run a command on the startup of an xterm?

user189942 picture user189942 · Jun 27, 2015 · Viewed 11.6k times · Source

How can I run a command on xterm startup i.e. when an xterm terminal is launched a the command is already executed?

I have edited the .bashrc file to add this line:

xterm "ls"

But this does not work.

Please suggest what should I do to acheive this.

Thanks.

Answer

frhack picture frhack · Jun 27, 2015

I use this:

-e /bin/bash -login

-e command [arguments]

Run the command with its command-line arguments in the rxvt window; also sets the window title and icon name to be the basename of the program being executed if neither -title (-T) nor -n are given on the command line. If this option is used, it must be the last on the command-line. If there is no -e option then the default is to run the program specified by the SHELL environment variable or, failing that, sh(1).

http://linux.die.net/man/1/rxvt