1、同时指定多个分割符 这时应该把分隔符写成放到方括号中,如$awk -F[ :/t] {print $1,$3} test 此时指定了空格,:号,tab三个作为分隔符 2、awk的key的变态用法 awk {a[$1,/t, $2] += $4} END {for (uin in a) printf(%s/t%d/n, uin, a[uin]) } test 用$1/t...
lshell.noarch : Python-based limited Shell yum install lshell configure file: /etc/lshell.conf ============================================ aliases : {ls:ls -l, cd:cd /home} allowed : [grep,cd,cp,sed,ls,pwd] ####允许使用的命令 ### forbidde...
一例shell脚本,用于替换文件中的文件路径,可以指定需要替换路径记录的文本、替换的文件目录、替换的文件类型。 此shell脚本的用法: 参数1、需要替换路径记录的文本,格式:老路径 老名称 新路径 新名称 参数2、需要替换的文件的目录 参数3、需要替换的文件...
一例shell脚本,用于检测文件是否存在,shell中-f参数检测指定文件存在与否。 例子,shell脚本检查文件是否存在。 #!/bin/bash # FILE=/etc/hosts if [ -f $FILE ]; then echo File ${FILE} exists else echo File ${FILE} does NOT exists fi...
linux shell脚本批量复制文件,并转换内容编码,也可以过滤掉不想转换的文件。 用shell脚本批量、递归 (不追溯链接) 复制文件、改变复制出的文件的内容编码、使用旧文件的 m 时间戳。 可以修改convertOrNot()函数,过滤掉不想转换的文件。 代码: #调用办法 e...
一段shell脚本,用于ping多台主机ip地址,命令行接收多个ip地址作为参数,将ping结果保存到文件host.txt中。 shell脚本连续ping多台主机: #!/bin/sh # #fileName:ping.sh # if test $# -eq 0 then echo Please input IP! else for ipstr in $* do ping -c5 $...
用linux shell脚本检测端口是否被占用,当某一端口被linux下进程占用时,可以尝试用此脚本检测下端口的占用状态。 shell脚本检测端口占用: #!/bin/bash # port=$1 echo check $port grep_port=`netstat -tlpn | grep \b$port\b` echo grep port is $grep_por...
分享一例shell脚本,实现linux ip地址的程序化配置,包括dhcp自动获取ip地址与手动配置ip地址二种情况。 linuxshell脚本: #!/bin/bash # 配置ip地址脚本 fun0 () { ipfile=/etc/sysconfig/network-scripts/ifcfg- e th0 hwaddr=`ifconfig |grep eth0 | aw k...
用shell脚本判断指定进程是否处于运行状态,linux shell脚本检测进程状态的方法,主要用到ps aux与grep命令。 shell脚本: #!/bin/bash # 判断python是否在运行 if ps aux | grep python /dev/null then echo Running else echo Stopped fi 说明: ps aux输出...
linux shell脚本批量检测端口是否占用,编写一段shell脚本检测端口占用情况。 以下的shell脚本中,用nc命令检测ports文件中端口是否被占用: #!/bin/bash cat ports | while read line do #nc -z -w 10 $line nc -z -w 2 $line 58422 /dev/null 21 if [ $? -e...