unix & Linux tutorial to learn _8

13.17 history list: set the size

For the Bourne shell family, HISTSIZE need to set environment variables. For example, to specify a list of store 50 history commands:

export HISTSIZE=50
set history = 50 \(~~~~~~\)//C-shell家族

13.18 history list Example: To avoid deleting the wrong file

Suppose you want a group called temp, temp_backup, extral and extra2 files. You consider entering the following command:

rm temp* extra?

However, you forget that there is an important document temp.important. If you enter the above command, then the file will also be deleted.
Avoid accidentally deleted a way that the first command with ls:

ls temp* extra?

Before, if found to have been forgotten files temp.important, you can no longer be like that with the rm command. If the file list in line with expectations. Ls can then be replaced and re-execute the rm command to delete all the files:

fc -s ls=rm
^ls^rm
\(~~~~~~\)//C-Shell家族

13.19 show & event number working directory in the shell prompt

See P273

13.20 autocomplete

shell Complete words Show all possible
Bash <Tab> <Tab><Tab>
Korn Shell <Esc><Esc> <Esc>=
C-Shell <Esc> ^D
Tcsh <Tab> ^D

13.21 autocomplete: Advanced Applications

See P277

13.22 for the fun and bet using auto-complete

See P279

13.23 command line editing: bindkey

See P280

13.24 Alias: alias, unalias

Alias is the name given to a command or a command. Aliases can be used as an abbreviation, or use an alias to create a custom variant of an existing command.
Suppose you find yourself frequently enter the following command:

ls -l temp*

If this command to assign an alias lt, it can be simplified by typing a command on the following command:

lt

Create an alias need to use the alias command. For the Bourne shell family, the syntax is:

alias [name=commands]
alias [name commands] \(~~~~~~\)//C-Shell家族

Both sides of the equal sign is determined with no spaces (there are such a request to create variables).
name is the alias name you want to create, and commands is a list containing one or more commands. example:

alias lt='ls -l temp*'
alias lt 'ls -l temp*'\(~~~~~~\)//C-Shell家族

Example: Create an acronym for the alias itself:

alias a = alias
Once the alias is defined, would be:
A = info 'DATE; WHO'

To display the meaning of aliases info, you can use:

alias information

To display all the aliases, you can enter the alias command without parameters:

alias

Use unalias command to remove the alias. The command syntax is:

unalias name
where name is the name of an alias. For example, to remove the alias just defined, you can use:
unalias info

If you want to also remove all aliases:

-a unalias \ (~ ~ ~ ~ \) // Bourne shell family
unalias * \ (~~~~~ \) // C-Shell family

Use the type command to view a particular article is not an alias. For example, before viewing info:

type info
info is aliased to 'date; who'

You can put all your favorite alias definitions in an initialization file. Whenever starting a new shell, the alias command will be executed automatically.

13.25 temporarily suspend alias

Suppose you find that when you use the ls command, almost always with the -l option. So, in order to save time typing in options, you can define the following alias:

alias ls="ls -l"

Now, simply enter the command itself, you can display the "long" list, no longer need to type options:

ls
This will generate a long list, just enter the following command as:
ls the -l

When using this alias, you will find that sometimes we want to run the original command, not an alias. For example, you do not want to run the command ls -l option. To temporarily suspend an alias, simply type a command at the beginning of the name of the \ (backslash) characters:

\ ls
This tells the shell to run the actual command itself, not an alias.

13.26 Alias ​​Example: To avoid deleting the wrong file

Earlier we discussed examples:

rm temp * extra?
To avoid deleting the wrong, we can first use ls, and then use the -s fc
LS the TEMP * Extra?
fc -s LS = RM

To use this command easier to use, we define an alias for the del command:

alias del='fc -s ls=rm'

For the C-Shell, see P824
once defined this del alias, first of all, we enter the ls command, and a description of the mode you want to delete a file. example:

? ls temp * extra
file name if the mode is displayed in line with our expectations, then you can enter:
del
so that you can delete the file.

13.27 Alias ​​Example: Reuse command from the history list

P285

13.28 Alias ​​Example: Display the name of the working directory in the shell prompt

P287

Guess you like

Origin www.cnblogs.com/cnyxj/p/11447184.html