shell programming combat 7

1. Calculation of the number of the digital document

   

2. The difference between the two machines compare files

#!/bin/bash

dir = / data / web

[-F /tmp/md5.list] &&> /tmp/md5.list # / tmp directory must exist, md5.list must be emptied or deleted files

find $dir/ -type f > /tmp/file.list
while read line
do
md5sum $line >> /tmp/md5.list # 循环追加
done </tmp/file.list

scp /tmp/md5.list B:/tmp/
[ -f /tmp/check_md5.sh ] && rm -f /tmp/check_md5.sh

# Script file to embed
CAT> << /tmp/check_md5.sh the EOF
#! / Bin / the bash
the dir = / Data / Web
n-= \ `-l /tmp/md5.list WC \` # for loops of line of the file can not have spaces, all the loop condition convert file line number
for i in \ `seq 1 \ $ n \` # $ n take the value of variables, but also off the righteous, or is the value of $ n
do
= file_name \ `Sed -n" \ $ I "P /tmp/md5.list | awk '{2} Print $' \`
MD5 = \ -n Sed `" \ $ I "P /tmp/md5.list | awk '{Print $. 1}' \ `
IF [-f \ $ file_name]
the then
md5_b = \` the md5sum \ $ file_name \ `
IF [\ $ md5_b! = \ $ MD5]
the then
echo" \ $ file_name has changed "
Fi
the else
echo "\ $ file_name IS Lost"
fi
DONE
EOF
scp /tmp/check_md5.sh B: / tmp /
SSH B "/ bin / bash /tmp/check_md5.sh"After connecting #ssh machine B, run / bin / bash /tmp/check_md5.sh

3. 批量杀进程

   

4. 统计网卡流量

   

5. 判断web服务的类型

   

Guess you like

Origin www.cnblogs.com/tanzhirong/p/11456526.html