Skip to content

Instantly share code, notes, and snippets.

@yerstd
Last active May 10, 2018 13:28
Show Gist options
  • Save yerstd/3ab562e255486928c772be6d9763d00c to your computer and use it in GitHub Desktop.
Save yerstd/3ab562e255486928c772be6d9763d00c to your computer and use it in GitHub Desktop.
log.sh
#!/bin/bash
cd /root/zzq
. ./host.sh
cd logs
for host in ${hosts[@]}; do
if [ ! -e $host ]; then
mkdir $host
fi
echo "========$host start========"
rsync -e "ssh -o StrictHostKeyChecking=no" -aP root@$host:"/var/logs/*2018*" ./$host
echo "========$host done========"
done
for dir in ./*; do
cd $dir
pwd
for file in ./*; do
echo $file
log=`grep 'sampleAction' $file | awk -F ':' '{print $2}'`
if [ "$log" ]; then
echo "$log\n" >> /root/zzq/big-log.txt
fi
done
cd ../
pwd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment