CMD List [6]

1.1         zcat

 

displays the contents of a gzipped or compressed file on the screen.

 

Syntax             zcat filenames

 

Option or argument

Function

Filenames

Specifies the compressed files you want to display.

 

The zcat command does the same thing as gunzip –c. See also gzip and gunzip.

 

Sample

 

You want to see the contents of a gzipped text file called important.stuff.gz. Type

 

zcat important.stuff.gz

 

2          Key

2.1         <Ctrl> [c]/[d]

Ctrl + C – cancel; Ctrl + D - exit

 

2.2         <Esc> [k]/[u]

<Esc>k displays the previous command that has been executed. User can press “k” more times to continually browse the sent commands.

On the contrary, <Esc>u will display the executed command that follows the displaying command.

 

3          Symbol

3.1         Comment ( # )

3.2         File redirection (> or >> or <)

< redirects input; > redirects output; >> redirects output and appends the information to the existing file.

e.g.

who > users (output of 'who' save into users)

who >> users (output of 'who' append after users)

true > access.log (clean file)

echo '' > access.log (clean file)

wc -l < users (count the line of users)

 

3.3         pipe ( | )

e.g.

|more - 'f' for forward, 'b' for backward, 'q' for quit, 'h' for help, '/' for search.

|pg     - 'q' for quit, 'h' for help.

cat users | wc -l (ditto)

ps | sort (sort process)

 

3.4         &

 

Set the command/script running in the backend.

e.g.

sort date > out &

nohup ksh /SAS/FTEND/sys/admin/pgm/sh/startMatnJobQ.sh 1>/dev/null 2>&1 &

 

stdin, stdout, stderr的文件描述符分别是0, 1, 2. 对于其他那些需要打开的文件, 保留了文件描述符39.

e.g.

&>filename       # stdoutstderr都重定向到文件"filename".

M>&N      # "M"是一个文件描述符, 如果没有明确指定的话默认为1.

0<&-, <&-       关闭stdin.

1>&-, >&-       关闭stdout.

 

exec 3>> ${OUT}

exec 2>&3

exec 1>&3

 

3.5         dot (.)

UNIX programs can never, ever modify the environment of their parents. A program can only modify the environment that later will be passed to its children.

If you write a program that executes the cd command, that cd will be effective within your program - but when the program finishes, you'll be back in your original (parent) shell. To solve it, use . or source command.

The source and . command read a script file into the current shell instead of starting a child shell.

e.g. Add below statement in the xxx.sh

. ${TOOLSCP}/wsd_db_mst_ld.sh $1 $2

 

3.6         Special directories (. or .. or /)

Dot directory: the current location.

Dot-dot directory: moves up one level, to the parent directory.

Slash: root

 

3.7         ‘’ “” ``

Same as Perl.

compare with Double quotes (“”), Apostrophe (‘’): 1 – can’t replace variable 2 – 反斜线不支持转义字符. 3 – 可以跨多行.

'' – Single Quote / Apostrophe, string no variable replacement

"" - Double quotes, string with variable replacement

`` - Backquote / Backtick, run the command, generate output as input

 

3.8         Wildcard

 

Option or argument

Function

?

Any one of character.

*

Zero or more characters.

[abc]  [a-c]

Either of a b c.

[!abc]  [!a-c]

Neither of a b c.

^x  ^[abc]

Start with x; start with either of a b c.

x$  [abc]$

End with x, end with either of a b c.

 

3.9         \

按文本含义解释后面接着的字符

 

3.10     Escape Sequence in Strings

符号

含义

\0

匹配空字符(ASCII NUL)。

\NNN

2 to 3 bytes of octal,最大值为\377

\n

匹配前面第n个捕获字串(十进制)。

\a

匹配警钟字符(BEL)。

\A

如果在字串的开头为真

\b

匹配退各字符(BS)。backspace

\b

在字边界为真

\B

不在字边界时为真

\cX

Control Character, e.g. \cC for control-C, \c[ for ESC, \c? for DEL.

\C

匹配一个字节(C字符),甚至在utf8中也如此(危险)

\d

匹配任何数字字符

\D

匹配任何非数字字符

\e

匹配逃逸字符(ASCII ESC,不是反斜杠)。

\E

结束大小写(\L\U)或者掩码(\Q)转换

\f

匹配进页字符(FF)。form feed

\G

如果在前一个m//g的匹配结尾位置时为真

\l

只把下一个字符变成小写

\L

\E以前的字母都变成小写

\n

匹配换行符字符(通常是NL,但是在Mac上是CR)。newline

\N{NAME}

匹配命名字符(\N{greek:Sigma})。

\p{PROP}

匹配任何有命名属性的字符

\P{PROP}

匹配任何没有命名属性的字符

\q

do not look for special pattern characters

\Q

引起(消元)直到\E前面的字符

\r

匹配返回字符(通常是CR,但是在Mac上是NL)。carriage return

\s

匹配任何空白字符。 [ \t\n\r\f]

\S

匹配任何非空白字符。

\t

匹配水平制表符(HT)。

\u

只把下一个字符变成标题首字符force next letter into uppercase

\U

大写(不是标题首字符)\E 以前的字符。

\w

匹配任何字符(字母数字加"_" )。 e.g. \w_

\W

匹配任何非字字符。 [^a-zA-Z0-9_]

\x{HEX}

1 to 2 bytes hex. If use {} then no limit to bytes of hex, may for Unicode.

\X

匹配Unicode里的组合字符序列字串。

\z

只有在字串结尾时为真

\Z

在字串结尾或者在可选的换行符之前为真。

 

3.11     Default variables

HOME

Home directory. e.g. echo $HOME

USER

User ID.

PATH

Which directories to search and the searched order.

SHELL

C shell (sh) or Korn shell (ksh).

set

Just type ‘set’ to check all.

 

3.12     Return code

0                    match

1     no match

>1   syntax error or file was inaccessible

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值