linux自用代码记事本

#中断命令名为analyze的任务
ps -e |grep "analyze" |awk '{print $1}'
kill $(ps -e |grep "analyze" |awk '{print $1}')
#批量生成文件夹
mkdir $(seq -f "08%02g" 1 2 20)
#筛选特定行
cat file | sed -r '1,5d'
cat file | sed -rn '6p'
#筛选特定列
cat file | awk -F ':' '{printf $2}'
#筛选文本,筛选,合并,选择
cat anarecord.log |grep -A1 'path dot' |sed '/--/d' |sed 'N;s/\n/:/' |awk -F ":" '{if($2>500) print $4}'
wc path* |awk '{if($1<500) print $4}'
#筛选文本,分段,加和
cat anarecord.log |grep "The length of path" |awk -F ":" '{print $2}' |awk 'BEGIN{sum=0} {sum=$1+sum} END{print sum/50}'
#expect脚本
#!/usr/bin/expect
set dir [lindex $argv 0]
set password [lindex $argv 1]
spawn ssh [email protected] mkdir /mnt/sdb1/ZMH/$dir
expect { 
"password:" { send "$password\r" }
}
expect eof
#bash脚本中使用expect脚本
#/bin/sh
local=$PWD
password=node1root
for i in $(seq -f '0%g' 6 1 9); do
    #echo $i
    for j in $(seq -f '%02g' 1 1 20); do
        if ls |grep "$i$j" &>/dev/null; then
dir=$i$j
cd $dir
/usr/bin/expect <<-EOF
set timeout -1
spawn ssh [email protected] mkdir /mnt/sdb1/ZMH/$i$j
expect { 
"password:" { send "$password\r" }
}
spawn scp FibreParameter.dat palabos0.dat RawData.dat record.dat [email protected]:/mnt/sdb1/ZMH/$dir
expect { 
"password:" { send "$password\r" }
}
expect eof
EOF
cd $local
        fi
    done
done
发布了15 篇原创文章 · 获赞 5 · 访问量 3675

猜你喜欢

转载自blog.csdn.net/qq_28632981/article/details/104294510