Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Way to type short word to execute a long command in CLI

Way to type short word to execute a long command in CLI
Thread Tools
Forum Regular
Join Date: Nov 2002
Status: Offline
Reply With Quote
Jan 21, 2003, 03:20 PM
 
Okay maybe the title is not 100% what I want to say but this is what I want to do.

I type in a command to execute a process on my ibook. But instead of having to type this long command over and trying to remember the command, is there a way to create a substitute command to execute this long command?

ie.

> passwd guest ###############################

so instead of having to type the above, I want to just type

> passwdguest

and so this command would actually execute

> passwd guest ###############################

I know something exist but I can't think of it to look it up.

Thanks
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jan 21, 2003, 04:37 PM
 
They're called aliases.

for tcsh (the default)
Add a line like this to .cshrc in your home directory.

Code:
alias passwdguest "passwd guest ###############################"
for bash
Add a line like this to .bashrc in your home directory.
Code:
alias passwdguest="passwd guest ###############################"
Open a new termical window for the changes to take affect, or you can type source ~/.cshrc or source ~/.bashrc for bash.

Lots of info to be had by typing man tcsh.
     
Junior Member
Join Date: Sep 2000
Status: Offline
Reply With Quote
Jan 22, 2003, 10:48 AM
 
Originally posted by aquaclear:

I type in a command to execute a process on my ibook. But instead of having to type this long command over and trying to remember the command, is there a way to create a substitute command to execute this long command?
Alternatively you could create a shell script that does the task for you. This also allows you to have more than one task under one command!

For example

#!/bin/sh

echo "Showing my home"
cd /home/james
ls

echo "Showing bin"
cd /usr/bin
ls

Saved as a text file called "view.sh" with executable permission would let you type

./view.sh

and do all the commands!

./
Nobody made a greater mistake than
he who did nothing because he could only
do a little. Edmund Burke
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:35 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2