我想在别名中插入不同的拼写变体,例如
cat
命令。我可以使用某个符号表示“或”吗,还是应该换行进行?alias at|cart|cst '/bin/cat'
cat
命令。我可以使用某个符号表示“或”吗,还是应该换行进行?alias at|cart|cst '/bin/cat'
alias
的帮助文档表明它可以一次性分配多个别名:alias: alias [-p] [name[=value] ... ]
Define or display aliases.
Without arguments, `alias' prints the list of aliases in the reusable
form `alias NAME=VALUE' on standard output.
Otherwise, an alias is defined for each NAME whose VALUE is given.
A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.
name=value
对:alias {at,cart,cst}='/bin/cat'
$ alias {at,cart,cst}='/bin/cat'
$ type at cart cst
at is aliased to `/bin/cat'
cart is aliased to `/bin/cat'
cst is aliased to `/bin/cat'
at
来说没什么帮助,但对于其他情况会有帮助):
% setopt correct % sl zsh: correct `sl' to `ls' [nyae]? y % setopt correctall % ls x.v11r4 zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n /usr/princton/src/x.v11r4 not found % ls /etc/paswd zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y /etc/passwd
If you press
y
when the shell asks you if you want to correct a word, it will be corrected. If you pressn
, it will be left alone. Pressinga
aborts the command, and pressinge
brings the line up for editing again, in case you agree the word is spelled wrong but you don't like the correction.
for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done
at
)使用。
alias kk='ll'
。 - pLumoat
作为cat
的别名使用。实际上,有一个用于调度任务的命令at
:https://askubuntu.com/a/339301/295286 - Sergiy Kolodyazhnyy