Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This kick-ass shell script can find anything from a mess
- # Then display how long it takes to do it.
- # ------------------------------ Some foreplay...
- SECONDS=0
- FINDSTR="${@:1}"
- # Filter out non-hex strings.....
- if ! [[ $FINDSTR =~ ^[0-9a-fA-F]+$ ]]; then
- echo "Try to find non-hex?"
- exit 1;
- fi
- # Make you lower(-case) and create gaps between them :)
- FINDSTR=" $(echo $FINDSTR | tr '[:upper:]' '[:lower:]' | sed 's/.\{4\}/& /g')"
- # Too long isn't quite confortable, right?
- if [ ${#FINDSTR} -ge 32 ]; then
- echo "Is it a bit... longer??" ;
- exit 2;
- fi
- # ------------------------------- Now let's do it
- cat /dev/urandom | hexdump | grep --color=always -m1 "$FINDSTR"
- # ------------------------------- Done
- duration=$SECONDS
- echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement