Skip to content

Instantly share code, notes, and snippets.

@edoz90 edoz90/cleanvba.zsh
Created Dec 31, 2018

Embed
What would you like to do?
Clean VBA: this script should remove unused variables in obfuscated VBAs (should work also for other files)
#!/usr/bin/env zsh
#
toclean=${1}
while read line; do
local length=$(echo -n ${line} | \wc -m)
if [[ ${length} -ge 50 ]]; then
local match=$(echo ${line} | \awk '{print $1}')
local file_match=$(\rg -i ${match} * -c | \awk -F ':' '{print $1}')
local num_match=$(\rg -i ${match} * -c | \awk -F ':' '{print $2}')
if [[ $(echo ${num_match} | \wc -l) -gt 1 || $((${num_match})) -ge 2 ]]; then
else
sed -i "/${match} = /d" ${file_match}
fi
fi
done < ${toclean}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.