1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-21 17:22:29 +00:00
gists/Script to copy all the logs with a certain filename (YYY-MM-DD_<name>.log) to a folder for the day, tar.gz the folder and send it to a remote host./tar-and-scp.sh
J. Fernando Sánchez f48bab94dd Move files
2021-10-30 15:23:01 +02:00

15 lines
325 B
Bash

#!/bin/bash
tosend=""
for i in *.log; do
dir=$(echo $i | awk '{split($1,a,"_"); print a[1]}');
if [ ! -d $dir ]; then
mkdir $dir;
fi;
mv $i $dir;
tosend="$tosend\n$dir"
done
for i in $(echo -e $tosend | uniq);do
echo Compressing $i
tar -zcvf $i.tar.gz $i
scp $i.tar.gz user@server
done