Solved

multiple commands on a single alias

Posted on 2004-08-31
6
323 Views
Last Modified: 2010-04-21
Can I setup multiple commands on a single alias.
For example, I want to have one alias that changes the directory, and launches an executable with specific parameters.

How can I do that, and what are the syntax for it?

alias mcd='cd /devt/vbs/ncr' 'ct co -nc'
0
Comment
Question by:Axter
6 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 300 total points
ID: 11942160
alias mcd='cd /devt/vbs/ncr;ct co -nc'
or
alias mcd='cd /devt/vbs/ncr && ct co -nc'
the && makes sure the first command returns without an error before trying the second, the first just runs them one after other
0
 
LVL 40

Assisted Solution

by:jlevie
jlevie earned 200 total points
ID: 11942211
In this case you could also do:

alias mcd="(cd /devt/vbs/ncr; ct co -nc)"

That will execute the change dir & command in a subshell which won't change the current working directory.
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 11942248
Hi Axter,

yes you can
alias mcd='cd /devt/vbs/ncr && ct co -nc'

second will be executed only if first is successful

Sunnycoder
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 45

Expert Comment

by:sunnycoder
ID: 11942257
doh ... sorry for the repetition of idea ... My network is not behaving very well today :-(
0
 

Expert Comment

by:Justsolutions
ID: 11942267
One other thing to be careful with.  The use of " or ' makes a BIG difference with
command substitution in your shell.  " allows variable substitution, ' does not.
0
 
LVL 30

Author Comment

by:Axter
ID: 11942377
Thanks for the very quick response... :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Skill Development 15 163
How to Insert a File Using Text Editor 9 80
Solaris 4.1.3 cloning and booting 13 72
Writing a UNIX script menu allowing for multiple options. 5 33
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now