Created
October 30, 2017 15:30
-
-
Save pascencio/02cbec72efd5ad5e5c2c12618ac467f8 to your computer and use it in GitHub Desktop.
Extraer logs de Weblogic 11g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LIST_ARCHIVOS="$(egrep -l '\<Jan\ 30\,\ 2017\ 4\:.*PM.*\>' *)" | |
CANT_ARCHIVOS="$(egrep -l '\<Jan\ 30\,\ 2017\ 4\:.*PM.*\>' * | wc -l)" | |
declare -a ARRAY_ARCHIVOS | |
declare -a ARRAY_LINEA_INICIAL | |
declare -a ARRAY_LINEA_FINAL | |
for (( i=1; i<=$CANT_ARCHIVOS; i++ )) | |
do | |
ARRAY_ARCHIVOS[$i]="$(echo $LIST_ARCHIVOS | cut -d ' ' -f $i)" | |
ARRAY_LINEA_INICIAL[$i]="$(egrep --text -n '\<Jan\ 30\,\ 2017\ 4\:.*PM.*\>' ${ARRAY_ARCHIVOS[$i]} | tail -n 1 | cut -d ':' -f 1)" | |
ARRAY_LINEA_FINAL[$i]="$(wc -l ${ARRAY_ARCHIVOS[$i]} | cut -d ' ' -f 1)" | |
if [ "${ARRAY_LINEA_INICIAL[$i]}" -eq "${ARRAY_LINEA_FINAL[$i]}" ]; then | |
mv ${ARRAY_ARCHIVOS[$i]} ../filtrados | |
else | |
ARRAY_LINEA_INICIAL[$i]="$(expr ${ARRAY_LINEA_INICIAL[$i]} + 1)" | |
sed -i".bak" "${ARRAY_LINEA_INICIAL[$i]},${ARRAY_LINEA_FINAL[$i]}d" ${ARRAY_ARCHIVOS[$i]} | |
mv ${ARRAY_ARCHIVOS[$i]} ../filtrados | |
fi | |
done | |
rm -f *.bak |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LIST_ARCHIVOS="$(egrep -l '\<Jan\ 30\,\ 2017\ 4\:.*PM.*\>' *)" | |
CANT_ARCHIVOS="$(egrep -l '\<Jan\ 30\,\ 2017\ 4\:.*PM.*\>' * | wc -l)" | |
declare -a ARRAY_ARCHIVOS | |
declare -a ARRAY_LINEA_INICIAL | |
for (( i=1; i<=$CANT_ARCHIVOS; i++ )) | |
do | |
ARRAY_ARCHIVOS[$i]="$(echo $LIST_ARCHIVOS | cut -d ' ' -f $i)" | |
aux="$(egrep --text -n '\<Jan\ 30\,\ 2017\ 4\:.*PM.*\>' ${ARRAY_ARCHIVOS[$i]} | head -n 1 | cut -d ':' -f 1)" | |
ARRAY_LINEA_INICIAL[$i]="$(expr $aux - 1)" | |
if [ "${ARRAY_LINEA_INICIAL[$i]}" -eq "0" ]; then | |
mv ${ARRAY_ARCHIVOS[$i]} ../filtrados | |
else | |
sed -i".bak" "1,${ARRAY_LINEA_INICIAL[$i]}d" ${ARRAY_ARCHIVOS[$i]} | |
mv ${ARRAY_ARCHIVOS[$i]} ../filtrados | |
fi | |
done | |
rm -f *.bak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment