标签:bash shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#echo $HISTFILE /root/.bash_history # echo $HISTFILESIZE HISTFILE指向的文件持久留存的历史命令条目 1000 # echo $HISTSIZE 当前bash进程所留存的历史命令条目数 1000 # history -d 123 删除历史列表中的第 123 条命令 # history -c 清空历史命令 # history 20 显示最近的 20 条命令 # history -a 追加当前bash进程的新历史命令至命令历史文件中 122 echo $HISTFILESIZE 123 history 124 history -d 123 125 history 126 history 20 # ! 122 调用历史列表中的命令 echo$HISTFILESIZE 1000 # !! 再次执行上一条命令 echo$HISTFILESIZE 1000 # !lsb 快速调用历史命令中执行的命令 lsb_release LSBVersion: :base- 4.0 -amd64:base- 4.0 -noarch:core- 4.0 -amd64:core- 4.0 -noarch:graphics- 4.0 -amd64:graphics- 4.0 -noarch:printing- 4.0 -amd64:printing- 4.0 -noarch |
1
2
3
4
5
6
|
# ls/etc/passwd /etc/passwd # cat 这里按esc键,然后按.就会调用/etc/passwd #!$ /etc/passwd -bash:/etc/passwd: Permission denied |
1
2
3
4
5
6
7
8
9
10
11
12
|
环境变量:HISTCONTROL # echo $HISTCONTROL 忽略重复的命令(连续且相同) ignoredups ignorespace 忽略以空格开头的命令 #export HISTCONTROL=ignorespace #echo $HISTCONTROL ignoredups ignoreboth:上面两个功能同时生效 使用方法: exportHISTCONTROL=参数 撤销HISTCONTROL的控制: unsetHISTCONTROL |
1
2
3
4
5
6
7
8
|
# mkdir -pv /tmp/x/{y1,y2}/{a,b}/ mkdir:created directory `/tmp/x‘ mkdir:created directory `/tmp/x/y1‘ mkdir:created directory `/tmp/x/y1/a/‘ mkdir:created directory `/tmp/x/y1/b/‘ mkdir:created directory `/tmp/x/y2‘ mkdir:created directory `/tmp/x/y2/a/‘ mkdir:created directory `/tmp/x/y2/b/‘ |
1
2
3
4
5
|
#mkdir -pv /tmp/{a,b}_{c,d}/ mkdir:created directory `/tmp/a_c/‘ mkdir:created directory `/tmp/a_d/‘ mkdir:created directory `/tmp/b_c/‘ mkdir:created directory `/tmp/b_d/‘ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# tree /tmp/ /tmp/ ├──a3 ├──a_c ├──a_d ├──b_c ├──b_d ├──ks-script-ILxZQr ├──ks-script-ILxZQr.log ├──test ├──test1 ├──x │ ├── y1 │ │ ├── a │ │ └── b │ └── y2 │ ├── a │ └── b └──yum.log 14directories, 3 files |
1
|
#tree /path/to/somedir |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# tree /tmp/mylinux/ /tmp/mylinux/ ├──bin ├──etc │ └── sysconfig │ └── etwork-scripts ├──sbin ├──usr │ ├── bin │ ├── lib │ ├── lib64 │ ├── local │ │ ├── bin │ │ ├── lib │ │ ├── lib64 │ │ └── sbin │ ├── sbin │ └── share └── var ├── lib ├── log └── run 20directories, 0 files |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# mkdir -pv /tmp/mylinux/{bin,sbin,etc/sysconfig/etwork-scripts,usr/{bin,sbin,local/{bin,sbin,lib,lib64},share,lib,lib64}, var /{log,run,lib}} mkdir:created directory `/tmp/mylinux‘ mkdir:created directory `/tmp/mylinux/bin‘ mkdir:created directory `/tmp/mylinux/sbin‘ mkdir:created directory `/tmp/mylinux/etc‘ mkdir:created directory `/tmp/mylinux/etc/sysconfig‘ mkdir:created directory `/tmp/mylinux/etc/sysconfig/etwork-scripts‘ mkdir:created directory `/tmp/mylinux/usr‘ mkdir:created directory `/tmp/mylinux/usr/bin‘ mkdir:created directory `/tmp/mylinux/usr/sbin‘ mkdir:created directory `/tmp/mylinux/usr/local‘ mkdir:created directory `/tmp/mylinux/usr/local/bin‘ mkdir:created directory `/tmp/mylinux/usr/local/sbin‘ mkdir:created directory `/tmp/mylinux/usr/local/lib‘ mkdir:created directory `/tmp/mylinux/usr/local/lib64‘ mkdir:created directory `/tmp/mylinux/usr/share‘ mkdir:created directory `/tmp/mylinux/usr/lib‘ mkdir:created directory `/tmp/mylinux/usr/lib64‘ mkdir:created directory `/tmp/mylinux/ var ‘ mkdir:created directory `/tmp/mylinux/ var /log‘ mkdir:created directory `/tmp/mylinux/ var /run‘ mkdir:created directory `/tmp/mylinux/ var /lib‘ |
1
2
3
4
|
# mkdir -pv $(date "+%Y-%m-%d-%H-%M-%S" ) mkdir:created directory ` 2014 - 11 - 11 - 19 - 11 - 29 ‘ [root@localhosttmp]# ls 2014 - 11 - 11 - 19 - 11 - 29 |
1
2
3
4
5
6
7
8
|
# alias aliascp= ‘cp -i‘ aliasl.= ‘ls -d .* --color=auto‘ aliasll= ‘ls -l --color=auto‘ aliasls= ‘ls --color=auto‘ aliasmv= ‘mv -i‘ aliasrm= ‘rm -i‘ aliaswhich= ‘alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde‘ |
1
|
# ls-d / var /l*[[:digit:]]*[[:lower:]] |
1
|
# ls-d /etc/[ 0 - 9 ]*[^ 0 - 9 ] |
1
|
# ls-d /etc/[^[:alpha:]][[:alpha:]]* |
1
2
|
#mkdir test1 # cp-a /etc/m*[^ 0 - 9 ] /tmp/test1 |
1
2
|
#mkdir test2 # cp-r /etc/*.d /tmp/test2 |
1
2
|
#mkdir test3 # cp-r /etc/[mnrp]*.conf /tmp/test3 |
1
2
3
|
#ls / var r 2 > /tmp/ var .err #ls / var 2 > /tmp/ var .out #ls / var r 2 >>/tmp/ var /err |
1
2
3
|
#ls / var &> /tmp/ var .out #ls / var &>> /tmp/ var .out COMMAND > /path/to/somefile 2 > & 1 |
标签:bash shell
原文地址:http://blog.csdn.net/dyllove98/article/details/41774963