next up previous 405
Next: Removing aliases
Up: Running a script
Previous: Executing a script by name


Using aliases to run a script

The second method is to define an alias. An alias is a shorthand for a long command to save typing. So in fact this method is just a variant of executing a script by name.

     % alias myscript /home/user1/dro/bin/myscript
Thereafter you would only enter myscript to run your script. Now this alias only applies to your current process. Even child processes derived from the current process will not inherit the alias. The way to make an alias global, so each new C-shell process recognises the alias, is to define the alias in your $HOME/.cshrc file. This file in your login directory defines the `environment' for each C-shell process.

Here is a simple .cshrc file. It sets some global variables: noclobber prevents accidentally overwriting an existing file and history sets the number of previous commands you can recall. It defines three aliases. The first lets you browse through a directory listing. The second reformats the output from df on Digital UNIX so that lines do not wrap. The third lists the largest 20 files in a directory. Finally .cshrc runs the script /star/etc/cshrc to define Starlink aliases (the source command is explained here).

     set noclobber
     set history = 50
     alias dsd 'ls -l \!* | more'
     alias dff "df \!* |awk \
      '{printf("\"%-20.20s%9.8s%9.8s%9.8s%9.8s %s\\n\",'$1,$2,$3,$4,$5,$6)}' "'"
     alias big20 'ls -l | sort -k 5 | tail -n 20'
     source /star/etc/cshrc


next up previous 405
Next: Removing aliases
Up: Running a script
Previous: Executing a script by name

C-shell Cookbook
Starlink Cookbook 4
Malcolm J. Currie
2006 November 26
E-mail:starlink@jiscmail.ac.uk

Copyright © 2013 Science and Technology Facilities Council