练习
njohao
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
shell编程for循环练习
1、判断/var/目录下所有文件的类型 for file in $(ls /var);do type=$(ls -ld /var/$file | grep -o ^. ) case $type in -) echo "/var/$file is a regular file." ;; d) echo "/var/$file is a directory.&am原创 2019-02-18 15:15:10 · 3733 阅读 · 1 评论 -
编写shell脚本,实现打印国际象棋棋盘
代码如下: #!/bin/bash #set chess cell's width read -p "Please set the chess cell's width( two space width as unit ):" width if [[ $width =~ "^[0-9]+$" ]];then echo "wrong width setting, check your inpu...原创 2019-03-01 09:29:33 · 1860 阅读 · 0 评论 -
while和until循环练习
1.用二个以上的数字为参数,显示其中的最大值和最小值 #!/bin/bash if [[ $# == 0 ]];then echo "no arguments" exit fi declare -i biggest=$1 declare -i smallest=$1 until [[ -z $1 ]];do if (( $1 > $biggest ));then big...原创 2019-03-01 16:16:49 · 623 阅读 · 0 评论 -
编写centos系统初始化脚本
脚本的组织结构 . ├── reset │ ├── configbash.sh │ ├── configvim.sh │ ├── configyum.sh │ ├── installpkg.sh │ └── offselinux.sh └── reset.sh 脚本入口代码 #!/bin/bash if [ "$EUID" != "0" ] ;then echo "mus...原创 2019-02-26 19:40:05 · 433 阅读 · 0 评论 -
数组练习
1.输入若干个数值存入数组中,采用冒泡算法进行升序或降序排序 #!/bin/bash declare -a number for (( i=0; i<20; i++ ));do number[$i]=$RANDOM done echo "before sort:" echo ${number[@]} declare -i n=20 for (( i=0; i<原创 2019-03-04 16:58:43 · 533 阅读 · 0 评论
分享