Shell-related usage
If usage
-Q does not output results, only make judgments
[Email protected] tmp]# if Grep-q ' ^daixuan: '/etc/passwd; Then echo "Daixuan text"; fi
, when/ETCPASSWD contains Daixuan, the output Daixuan test
Case usage
[Email protected] tmp]# vim case.sh
#/bin/bashread -p "please input a number: " nm=$[$n%2]echo $mcase $m in 1) echo "The number is jishu." ;; 0) echo " the number is oushu." ;; *) echo "It is not jishu or oushu." ;; Esac
[Email protected] tmp]# sh case.sh
Please input a number:12
0
The number is Oushu.
[Email protected] tmp]# sh case.sh
Please input a number:11
1
The number is Jishu.
[Email protected] tmp]# sh case.sh
Please input a number:abcdef
0
The number is Oushu.
For usage
Use of SED
[[email protected] tmp]# SEQ 1 10
1
2
3
4
5
6
7
8
9
10
[[email protected] tmp]# SEQ 1 2 10
1
3
5
7
9
[[email protected] tmp]# seq 10-2 1
10
8
6
4
2
[Email protected] tmp]# Seq-w 1 10
01
02
03
04
05
06
07
08
09
10
[Email protected] tmp]# vim for.sh
#/bin/bashfor i in ' seq 1 ';d o echo $idone
[Email protected] tmp]# sh for.sh
This article is from the "Daixuan" blog, make sure to keep this source http://daixuan.blog.51cto.com/5426657/1739414
Shell-related usage