Skip to content

Instantly share code, notes, and snippets.

@sogaoh
Created November 13, 2015 06:29
Show Gist options
  • Save sogaoh/2e9db036d4224eb63ef7 to your computer and use it in GitHub Desktop.
Save sogaoh/2e9db036d4224eb63ef7 to your computer and use it in GitHub Desktop.
#!/bin/sh
while read LINE ;do
i=0
for inline in $LINE ;do
case $inline in
*'@'*) echo $inline \
| gawk '{a=substr($0,1,match($0,"@")-1);\
c=gensub(/[a-z]|[0-9]|[A-Z]/,"*","g",a);\
b=substr($0,match($0,"@"));printf"%s%s",c,b}' ;;
*) echo -n "$inline ";;
esac
done
echo
done < "$1"
@sogaoh
Copy link
Author

sogaoh commented Nov 13, 2015

Execute sample:

./mailmask.sh maillog.txt > maskedlog.txt

refs:
http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1116584216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment