Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This kick-ass shell script can find anything from a mess
  4. # Then display how long it takes to do it.
  5.  
  6. # ------------------------------ Some foreplay...
  7. SECONDS=0
  8. FINDSTR="${@:1}"
  9.  
  10. # Filter out non-hex strings.....
  11. if ! [[ $FINDSTR =~ ^[0-9a-fA-F]+$ ]]; then
  12. echo "Try to find non-hex?"
  13. exit 1;
  14. fi
  15.  
  16. # Make you lower(-case) and create gaps between them :)
  17. FINDSTR=" $(echo $FINDSTR | tr '[:upper:]' '[:lower:]' | sed 's/.\{4\}/& /g')"
  18.  
  19. # Too long isn't quite confortable, right?
  20. if [ ${#FINDSTR} -ge 32 ]; then
  21. echo "Is it a bit... longer??" ;
  22. exit 2;
  23. fi
  24.  
  25. # ------------------------------- Now let's do it
  26. cat /dev/urandom | hexdump | grep --color=always -m1 "$FINDSTR"
  27.  
  28. # ------------------------------- Done
  29. duration=$SECONDS
  30. echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement