| Character(s) | Meaning |
|---|---|
| * | match zero or more characters |
| ? | match any single character |
| [list] | match any character in list |
| [lower-upper] | match any character in range between lower and upper |
| str{str1, str2, ...} | expand different parts with common str |
| ~ | your home directory |
| ~user | home directory of user |
| Character(s) | Meaning |
|---|---|
| `cmd` | execute cmd and substitute output (command substitution) |
| \c | escape character c (take literally) |
| 'str' | string characters taken literally. Quotes everything except ' and ! |
| "str" | allow command substitution and variable substitution. Quotes everything except !, $, \ and ` |
| Character(s) | Meaning |
|---|---|
| <Space> | command argument separator |
| <Tab> | command argument separator |
| <Return> | command argument terminator |
| $ | variable identifier |
| * [ ] ? { } ~ - | file expansion |
| < > & ! | redirection |
| ! ^ | history |
| | | pipe |
| ; | command delimiter |
| ( ) | command group |
| \ ' " | quoting |
| ` | command substitution |
| & | background execution |
But it can be more:
Aliases can have arguments, pipes, and variables; they execute
faster than shell scripts and if you place them in .cshrc
file in your home directory, they are available at any time!
Example: count the plain files
% alias files 'ls -l | grep ^- | wc -l'
You can store a number of commands in a history list (you set this number by:
% set history = number) and you can refer to them later on without having to retype commands or parts of commands.
If you are using the Tenex C shell (tcsh) instead of the C shell, you can use the cursor positioning keys (↑, ↓) to go through the history list and the other keys (←, →) to modify the current command.
Format: command [word] [modifier]
| Command | From History List |
|---|---|
| !n | command with number n |
| !! | last command |
| !-n | nth command from last one |
| !str | last command starting with str |
| !?str? | last conmmand with str anywhere in command line |
| !?str?% | produce argument from last command with str |
| !{str1}str2 | last command with str1, append with str2 |
| ^str1^str2 | substitute str2 for str1 in last command |
| Word | Command |
|---|---|
| :0 | command name |
| :n | nth word |
| :^ (!^) | first word (of last command) |
| :$ (!$) | last word (of last command) |
| :% | word matched by ?str? search |
| :n-m | nth through mth words |
| :-n | 0 through nth words |
| :n- | n through next-to-last word |
| :n* | n through last word |
| :* (!*) | first through last word (of last command) |
| Modifier | Meaning | /disk1/users/peter/F90/program.o |
|---|---|---|
| :e | pathname extension (BSD) | o |
| :h | pathname head | /disk1/users/peter/F90 |
| :r | pathname root (no extension) | /disk1/users/peter/F90/program |
| :t | pathname tail | program.o |
| :q | quote wordlist | |
| :x | quote individual words | |
| :& | repeat previous substitution | |
| :g& | repeat previous substitution globally | |
| :s/str1/str2/ | substitute str2 for str1 | |
| :g[hrtes] | modify all words in wordlist using specified modifier |
Example:
% set file = /disk1/users/peter/F90/program.o % echo $file:e o % echo $file:h /disk1/users/peter/F90 % echo $file:r /disk1/users/peter/F90/program % echo $file:t program.o % echo $file:r:t program % program program started at xx-xx-xxxx program execution in progress ... **** program terminated ok **** % history 222 9:35 setenv DISPLAY terminal-name:0.0 223 9:40 alias files 'ls -l \!* | grep ^- | wc -l' 224 9:42 set file = /disk1/users/peter/F90/program.o 225 10:00 echo $file:e 226 10:03 echo $file:h 227 10:05 echo $file:r 228 10:12 echo $file:t 229 10:13 echo $file:r:t 230 10:14 program 231 10:14 history % !226 echo $file:h /disk1/users/peter/F90 % !e echo $file:r:t program % !223:1 files 5 % echo $!224:^ /disk1/users/peter/F90/program.o % echo "$!225" o % echo '$!226' $!226 % alias cd 'set alt = $cwd; \ ? chdir \!*; \ ? if (($status == 0) && ($alt+1 != $cwd+1)) set old = $alt; \ ? set prompt = "$cwd:t >"; \ ? if ((-e .README) && (!-z .README)) more .README' % alias - 'set back = $old;set old = $cwd;cd $back;unset back' % cd peter >pwd /disk1/users/peter peter >- F90 >