Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ## Terra address generator
- ## Search addresses with a word.
- ##
- ## ATTENTION! Cannot run two processes in parallel,
- ## causes inode issue: "Too many open files"
- ## and also swap exaustion.
- ## Config
- word1='yyyy'
- word2=''
- n=5 #how much addresses to find
- #where to search
- # 1 - search word1 in any place
- # 2 - search word1 in the begining only, straight after terra1
- # 3 - search word1 in end only
- # 4 - search word1 in the begining and word2 in the end simultaniously
- where=2
- ## Main code starts here
- case $where in
- 1) echo Search '"'$word1'"' in any place;;
- 2) echo Search '"'$word1'"' in the begining only, straight after terra1;;
- 3) echo Search '"'$word1'"' in the end;;
- 4) echo Search '"'$word1'"' in the beginning and '"'$word2'"' in the end simultaniously;;
- esac
- while [ $n -gt 0 ]; do
- found='false'
- s=$(terrad keys add 1 --dry-run 2>&1)
- address=$(echo "$s" | head -4 | tail -1 | sed -e 's/.*address: \([0-9a-z]*\)/\1/')
- #echo $address
- case $where in
- 1)
- #echo Search '"'$word1'"' in any place
- [ -z "${address##*$word1*}" ] && found='true'
- ;;
- 2)
- #echo Search '"'$word1'"' in the begining only, straight after terra1
- [ -z "${address##terra1$word1*}" ] && found='true' && echo found
- ;;
- 3)
- #echo Search '"'$word1'"' in the end
- [ -z "${address##*$word1}" ] && found='true'
- ;;
- 4)
- #echo Search '"'$word1'"' in the beginning and '"'$word2'"' in the end simultaniously
- [ -z "${address##terra1$word1*$word2}" ] && found='true'
- ;;
- esac
- if [ "$found" = 'true' ]; then
- echo $address >> terra.log
- echo "$s" | tail -1 >> terra.log
- echo '' >> terra.log
- n=$((n-1))
- echo address stored
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment