shell总结

Wesley13
• 阅读 609

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

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
5个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Wesley13 Wesley13
3年前
PPDB:今晚老齐直播
【今晚老齐直播】今晚(本周三晚)20:0021:00小白开始“用”飞桨(https://www.oschina.net/action/visit/ad?id1185)由PPDE(飞桨(https://www.oschina.net/action/visit/ad?id1185)开发者专家计划)成员老齐,为深度学习小白指点迷津。
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Wesley13 Wesley13
3年前
P2P技术揭秘.P2P网络技术原理与典型系统开发
Modular.Java(2009.06)\.Craig.Walls.文字版.pdf:http://www.t00y.com/file/59501950(https://www.oschina.net/action/GoToLink?urlhttp%3A%2F%2Fwww.t00y.com%2Ffile%2F59501950)\More.E
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Android蓝牙连接汽车OBD设备
//设备连接public class BluetoothConnect implements Runnable {    private static final UUID CONNECT_UUID  UUID.fromString("0000110100001000800000805F9B34FB");
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
11个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这