摘要:
awk是文本处理工具,功能小结如下: 1、条件表达式 [root@centos17 shell]# awk -F: '$3>1&&$3<3{print $0}' /etc/passwd daemon:x:2:2:daemon:/sbin:/sbin/nologin [root@centos17 sh 阅读全文
2020年10月5日 #
摘要:
阶乘计算 版本一: [root@centos17 shell]# sh -v factorial.sh #!/bin/bash factorial() { factorial1=1 for((i=1;i<=5;i++));do factorial1=$((factorial1*i)) done ec 阅读全文
摘要:
#!/bin/bash 官方推荐写法 #/usr/bin/env bash 最好的写法 #!/usr/bin/bash #!/bin/sh #!/usr/sh 后三种写法,根据不同的linux版本,路径会有所改变导致程序无法识别。可以使用#/usr/bin/env bash来替代。 阅读全文
摘要:
关联数组 [root@centos17 shell]# cat shells_count.sh #!/bin/bash #login shell counts declare -A shells while read line do type=`echo $line|awk -F":" '{prin 阅读全文