Solved

multiple commands on a single alias

Posted on 2004-08-31
6
329 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

705 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