reprocesoByUser.sh
#!/bin/bash
# Bash Guide for Beginners: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
# Bash Guide for awk: http://www.lapipaplena.net/awk-algunos-apuntes/
usersx=( user1 user2 user3 )
TARGET="./caching/2017"
findByUser() {
for file in $(find "$TARGET" -type f -name '*.gz'); do
filename=$(basename "$file")
dirnamefile=$(dirname "$file")
echo "################# $1 -> $filename"
gunzip < "$file" | sed '/^#/ d' > ./REprocess/$1_$filename
awk "/$1/ && (/2017-09-07/ || /2017-09-08/ || /2017-09-09/) {print}" ./REprocess/$1_$filename > ./REprocess/$1_$filename.tmp
if [ -s ./REprocess/$1_$filename.tmp ]; then
echo "################# Compress..."
gzip ./REprocess/$1_$filename.tmp
fi
if [ -f ./REprocess/$1_$filename ]; then
echo "################# Removing... $1_$filename"
rm -r ./REprocess/$1_$filename
fi
if [ -f ./REprocess/$1_$filename.tmp ]; then
echo "################# Removing... $1_$filename.tmp"
rm -r ./REprocess/$1_$filename.tmp
fi
done #fin for files
}
for user in "${usersx[@]}"; do
findByUser $user
done #fin for users
Comentarios
Publicar un comentario