shell总结

1、Compound commands

Compound commands overview
Grouping
{ …; } command grouping
( … ) command grouping in a subshell
Conditionals
[[ ... ]] conditional expression
if …; then …; fi conditional branching
case … esac pattern-based branching
Loops
for word in …; do …; done classic for-loop
for ((x=1; x<=10; x++)); do ...; done C-style for-loop
while …; do …; done while loop
until …; do …; done until loop
Misc
(( ... )) arithmetic evaluation
select word in …; do …; done user selections

2、Expansions and substitutions

Introduction to expansions and substitutions
{A,B,C} {A..C} Brace expansion
~/ ~root/ Tilde expansion
$FOO ${BAR%.mp3} Parameter expansion
`command` $(command) Command substitution
<(command) >(command) Process substitution
$((1 + 2 + 3)) $[4 + 5 + 6] Arithmetic expansion
Hello <---> Word! Word splitting
/data/*-av/*.mp? Pathname expansion

3、Builtin Commands

Declaration commands
Commands that set and query attributes/types, and manipulate simple datastructures.
Alt Type
declare Display or set shell variables or functions along with attributes. typeset builtin
export Display or set shell variables, also giving them the export attribute. - special builtin
eval A common misspelling of "evil" - special builtin
local Declare variables as having function local scope. - builtin
readonly Mark variables or functions as read-only. declare -r special builtin
unset Unset variables and functions. - special builtin
shift Shift positional parameters - special builtin
Control flow and data processing
Commands that operate on data and/or affect control flow.
Alt Type
colon "true" null command true special builtin
dot Source external files source special builtin
false Fail at doing nothing - builtin
continue / break continue with or break out of loops. - special builtin
let Arithmetic evaluation - an old fashioned way. - builtin
return Break out of a function, returning the specified exit status. - special builtin
[ The classic test command. test builtin
Process and Job control
Commands related to jobs, signals, process groups, subshells.
Alt Type
exec Replace the shell, set redirections. - special builtin
exit Exit the shell. - special builtin
trap Set traps. - special builtin
times Display process times. - special builtin
wait Wait for background jobs and asynchronous lists. - builtin
I/O
Commands for reading/parsing input, or producing/formatting output of standard streams.
Alt Type
coproc Co-processes: Run a compound command in the background with async I/O. - keyword
echo Create output from args. - builtin
mapfile Create arrays from lines of input readarray builtin
printf "advanced echo." - builtin
read Build variables or arrays from input streams. - builtin
Configuration and Debugging
Commands that modify shell behavior, change special options, assist in debugging.
Alt Type
caller Identify/print execution frames. - builtin
set Control positional parameters and shell behaviour. - special builtin
shopt set/get shell options. - builtin
整理自: http://wiki.bash-hackers.org/start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值