Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running two commands in one line

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
Hi,

how can I do this

cd /app/myapp
./myapp.ksh

in one line?

Thanks,

Chris
 
Another way:
cd /app/myapp && ./myapp.ksh


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
These are not shell specific.
PHV's is better, because it will not try to run myapp.ksh in case you can't cd to /app/myapp.
 
ls && ps

Command 2 will only run if command 1 runs Ok

use ls || ps

ps would only run if ls failed.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant.
 
> Are these shell specific?

Technically yes, but they work on all major shells, so realistically, no.
 
I've just tried them in ksh,csh,psh,bash on AIX, Solaris, Tru64 and it seemed to work in all cases.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top