LINUX TIPS AND TRICKS --- November 27, 2000

Published by ITworld.com, the IT problem-solving network
http://www.itworld.com/newsletters

--------------------------------------------------------------------------------

Command Aliases
By Danny Kalev

The 'alias' command enables you to create another name for a command. 
The alias doesn't replace the original command, though; it's simply a 
synonym for it. You define an alias using the 'alias' command followed 
by an equal sign and the command that the alias will stand for. For 
example, the following command defines 'list' as an alias for 'ls':

    $alias list=ls

You use this alias as you would use the original 'ls' command:

    $list
    mypog.c     myprog.o

Command Options and Parameters 
To include command options in an alias, enclose the command and its 
option(s) in single quotes:

    $alias sizes='ls -s'

The -s option lists files with their sizes in blocks. Therefore, the 
alias 'sizes' displays the files in the current directory with their 
sizes in blocks:

    $sizes
    mypog.c 6     myprog.o 12

You may include command parameters in an alias. The following alias 
displays only files with the .c extension:

    $alias listc='ls *.c'
    $listc 
    mypog.c 

You can use an exiting command name as an alias, too. In this case, the 
alias hides the original command. Use this feature to hide dangerous 
commands that might delete files inadvertently, change their names, 
etc. Let's look at a concrete example. To ensure that 'mv' command 
doesn't overwrite exiting files, define an alias called 'mv' that 
overrides the 'mv -i' command (the -i option queries the user before 
deleting existing files):

    $alias mv='mv -i'

Listing and Canceling Existing Aliases
To list all the aliases in effect, use the 'alias' command without 
additional parameters:

    $alias
    list = ls -s
    sizes = ls -s
    listc = ls *.c
    rm = rm -i  

To cancel an exiting alias, use the 'unalias' command followed by the 
alias you wish to remove:

    $unalias listc


About the author(s)
----------------
Danny Kalev is a system analyst and software engineer with more than 10 
years of experience, specializing in C++ and object-oriented analysis 
and design on various platforms including VMS, DOS, Windows, Unix, and 
Linux. His technical interests involve code optimization, networking, 
and distributed computing. He is also a member of the ANSI C++ 
standardization committee and the author of ANSI/ISO C++ Professional 
Programmer's Handbook (Que, 1999). Contact him at linuxnl@excite.com. 

--------------------------------------------------------------------------------

ADDITIONAL RESOURCES

Getting the most from your shell 
A helpful guide to command-line editing, aliases and functions, and 
shell programming

http://www.itworld.com/jsw/lintps_nl/swol-10-2000/swol-1027-unixshell.html

Quick lessons on shell programming 
How to start writing your own shell scripts

http://www.itworld.com/jsw/lintps_nl/swol-09-1997/swol-09-unix101.html

Get your (network) fax in order 
Send faxes from your Linux machine using HylaFAX

http://www.itworld.com/jlw/lintps_nl/lw-1999-06/lw-06-hylafax_p.html

--------------------------------------------------------------------------------

COMMUNITY DISCUSSIONS

Hone your Linux development skills, share your expertise, and put out 
the occasional call for help in this discussion for programmers of all 
levels.
http://www.itworld.com/jump/lintps_nl/forums.itworld.com/webx?14@@.ee6b652/193!skip=133

Linux is making its presence felt on the desktop, but is it stable and 
polished enough for prime time? Talk distributions, window managers, 
themes, and desktop politics here. 
http://www.itworld.com/jump/lintps_nl/forums.itworld.com/webx?14@@.ee6b663/285!skip=235

--------------------------------------------------------------------------------

CONTACTS

* For editorial comments, write Andrew Santosusso, Associate Editor, 
  Newsletters at: andrew_santosusso@itworld.com

* For advertising information, write Dan Chupka, Account Executive at:
  dan_chupka@itworld.com

* For recruitment advertising information, write Jamie Swartz, Eastern
  Regional Sales Manager at: jamie_swartz@itworld.com or Paul Duthie,
  Western Regional Sales Manager at: paul_duthie@itworld.com

* For all other inquiries, write Jodie Naze, Product Manager, 
  Newsletters at: jodie_naze@itworld.com

--------------------------------------------------------------------------------

PRIVACY POLICY
http://www2.itworld.com/CDA/ITW_Privacy_Policy 

Copyright 2000 ITworld.com, Inc., All Rights Reserved.

http://www.itworld.com
