Each shell has its own set of features. Those of the C Shell are discussed
below.
Modifying previous events: Allows you to correct typos in previous command,
or modify it to create a new command.
Aliases: The alias command allows you to define new commands. Useful for
creating shorthands for longer commands. The syntax is.
Filename Generation: When you give the shell abbreviated filenames which
contain special characters (metacharacters), it can generate filenames
which match existing files. Some examples appear below:
Filename Completion: The shell will complete a filename for you if you
type in only enough characters to make the name unique. This feature is
a great time saver and helps to prevent typos when trying to type long
filenames.
To use filename completion, you need to set filec, either on the command
line or in one of your initialization files.
- Command history: The history mechanism maintains a list of recently used command lines, called events. Provides a shorthand for reexecuting previous commands. To use history:
- Set the history variable:
- Issue the history command and view the output:
- To save history events across all login sessions, set the savehistory variable:
- Event reexecution: Allows you to specify a shorthand for reexecuting a previous event. Works with the history list.
set history = 100
history 35 12:34 sort < unsorted > sorted.list 36 12:34 cat sorted.list 37 12:35 ls * > unsorted 38 12:35 cat unsorted 39 12:35 ls 40 13:06 history 41 13:08 alias 42 13:11 ls 43 13:11 vi .cshrc
set savehistory = 50
!! - repeats last command !number - repeats numbered command from history list !string - repeats last command starting with string
^old^new - changes the string "old" to the string "new" in the last command issued !number:s/old/new/ - changes numbered command from history list; substitutes the string "old" with the string "new". Note that there is no space between number and :
alias entered_command executed_commandSome examples:
alias m more alias rm "rm -i" alias h "history -r | more" alias xpvm /source/pd/xpvm/src/RS6K/xpvmTo view all current aliases:
aliasTo remove a previously defined alias:
unalias alias_name
ls *.txt - list files with .txt suffix ls [abc]* - list files with names that start with a, b or c lpr prog?.c - print files named prog?.c where ? is any character cd ~jsmith - change to user jsmith's home directoryYou can "turn off" filename generation by setting the noglob variable. This will permit special characters to be interpreted literally. For example:
set noglob
set filecThen, when specifying a filename, type the part which is unique and hit the escape key (C shell) or tab key (TC Shell). For example, if you had a directory with a long name, such as "Introduction.UNIX.Filesystems", you could cd to that directory by using the cd command with only a portion of the file's name, provided that the portion you specify is unique (no other files have similar names)
cd IntroNote: typing a portion of a filename and then hitting CTRL-D instead of ESCape or TAB will display a list of the filenames which match.
0 comments:
Post a Comment