案例一:打印所有存储信息
# df -a
案例二:以方便人类阅读的方式打印存储信息
# df -h
案例三:打印存储的 inode 信息
# df -i
案例三:打印存储的格式
# df -T
# df -a
# df -h
# df -i
# df -T
-bash: /dev/null: Permission denied
# rm -f /dev/null;mknod /dev/null c 1 3;chmod 666 /dev/null
1) -b 排序时忽略每行前面的空格
2) -c 检查是否已排序
3) -f 排序时忽略大小写字母
4) -n 按照数值到大小进行排序
5) -o 将排序结果导入到指定文件
6) -r 以相反的顺序进行排序
7) -t 指定排序的分隔符
8) -k 以指定的列进行排序
# cat test.txt
3
5
4
2
1
# sort -c test.txt
sort: test.txt:3: disorder: 4
(补充:这里以检查 test.txt 文件里的排列为例)
# cat test.txt
3
5
4
2
20
1
# sort -n test.txt
1
2
3
4
5
20
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
c
e
d
b
a
# sort test.txt
a
b
c
d
e
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
c
e
d
b
a
# sort -r test.txt
e
d
c
b
a
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
3 d
5 c
4 a
2 e
1 b
# sort test.txt
1 b
2 e
3 d
4 a
5 c
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
3 d
5 c
4 a
2 e
1 b
# sort -k2 test.txt
4 a
1 b
5 c
3 d
2 e
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
10.0.200.10
172.16.50.10
192.168.100.1
192.168.100.10
172.16.50.1
10.0.200.1
# sort test.txt
10.0.200.1
10.0.200.10
172.16.50.1
172.16.50.10
192.168.100.1
192.168.100.10
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
10.0.200.10
172.16.50.10
192.168.100.1
192.168.100.10
172.16.50.1
10.0.200.1
# sort -t'.' -k3n test.txt
172.16.50.1
172.16.50.10
192.168.100.1
192.168.100.10
10.0.200.1
10.0.200.10
(补充:这里以排列 test.txt 文件里的列为例)
<command> &> <file>
或者:
<command> >& <file>
<command> 1> <file>
或者:
<command> > <file>
<command> 2> <file>
<command> &>> <file>
或者:
<command> >>& <file>
<command> 1>> <file>
或者:
<command> >> <file>
<command> 2>> <file>
<command> 2&>1
或者:
<command> 2>&1
<command> 1&>2
或者:
<command> 1>&2
<command> &> /dev/null
或者:
<command> &>> /dev/null
或者:
<command> >& /dev/null
或者:
<command> >>& /dev/null
或者:
<command> 1> /dev/null 2>&1
或者:
<command> 1>> /dev/null 2>&1
或者:
<command> 1> /dev/null 2>>&1
或者:
<command> 1>> /dev/null 2>>&1
或者:
<command> 2> /dev/null 1>&2
或者:
<command> 2>> /dev/null 1>&2
或者:
<command> 2> /dev/null 1>>&2
或者:
<command> 2>> /dev/null 1>>&2
(补充:通过此种方法输出信息就既不会显示出来也不会被重定向到一个文件里)
1) seq <option> <first number>
2) seq <option> <first number> <last number>
3) seq <option> <first number> <increment> <last number>
1) -f 指定序列的格式
2) -s 指定序列的间隔符
3) -w 使序列宽度相同
4) –equal-width 使序列宽度相同
# seq 5
1
2
3
4
5
(补充:这里以打印 1 到 5 的数字序列为例)
# seq 3 7
3
4
5
6
7
(补充:这里以打印 3 到 7 的数字序列为例)
# seq 4 2 8
4
6
8
(补充:这里以打印 4 到 8 数值差距为 2 的数字序列为例)
# seq -f "num%g" 5
num1
num2
num3
num4
num5
(补充:这里以打印 1 到 5 并且将 num 作为前缀的数字序列为例)
# seq -f "num%3g" 5
num 1
num 2
num 3
num 4
num 5
(补充:这里以打印 1 到 5 并且将 num 和 2 个空格作为前缀的数字序列为例)
# seq -f "num%03g" 5
num001
num002
num003
num004
num005
(补充:这里以打印 1 到 5 并且将 num 和 2 个 0 作为前缀的数字序列为例)
# seq -s '' 5
12345
(补充:这里以打印 1 到 5 并且没有间隔符的数字序列为例)
# seq -s ' ' 5
1 2 3 4 5
(补充:这里以打印 1 到 5 并且以空格作为间隔的数字序列为例)
# seq -s '#' 5
1#2#3#4#5
(补充:这里以打印 1 到 5 并且以 # 作为间隔的数字序列为例)
# seq -w 1 10
01
02
03
04
05
06
07
08
09
10
或者:
# seq --equal-width 1 10
01
02
03
04
05
06
07
08
09
10
# a=5
# seq $a
1
2
3
4
5
(补充:这里以将变量 a 的值设置为 5 ,并且打印 1 到变量 a 的值的数字变量为例)
# seq 1 5 > test.txt
# cat test.txt
1
2
3
4
5
或者:
# seq 1 5 | xargs -I{} echo {} > test.txt
# cat test.txt
1
2
3
4
5
(补充:这里以打印 1 到 5 的数字序列并导入到 test.txt 文件为例)