Last active
July 29, 2016 17:58
-
-
Save Rafhack/22ad8bf83a0917b34566 to your computer and use it in GitHub Desktop.
Procurar strings duplicadas no Strings.xml
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 | |
while getopts ":f:o:" p; do | |
case "${p}" in | |
f) | |
infile=${OPTARG} | |
;; | |
o) | |
outfile=${OPTARG} | |
;; | |
esac | |
done | |
tested=\; | |
noscan=("build_ambiente" "app_name") | |
rdom () { | |
local IFS=\> | |
read -d \< E C | |
local ret=$? | |
TAG_NAME=${E%% *} | |
ATTRIBUTES=${E#*} | |
return $ret | |
} | |
parse_dom() { | |
eval local $ATTRIBUTES | |
if [[ $name != "" ]] && [[ ! $noscan[@] =~ $name ]]; then | |
if [[ $1 == "" ]]; then | |
if [[ $tested != *\;"$C"\;* ]]; then | |
tested+="$C"\; | |
iterate_dom "$C" | |
fi | |
elif [[ $1 == "$C" ]]; then | |
those[$count]=$(echo $name "=" \"$C\") | |
(( count++ )) | |
fi | |
fi | |
} | |
iterate_dom() { | |
count=0 | |
unset those | |
while rdom; do | |
parse_dom "$1" | |
done < $infile 2>/dev/null | |
if [[ ${#those[@]} > 1 ]]; then | |
printf '%s\n' "${those[@]}" | tee -a $outfile | |
echo | tee -a $outfile & echo | tee -a $outfile & echo | tee -a $outfile | |
fi | |
} | |
if [[ $outfile == "" ]]; then | |
echo "-f xml -o out" | |
exit 1 | |
fi | |
if [[ $infile == *.xml ]]; then | |
echo > $outfile | |
iterate_dom | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment