SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ export LANG="en_US.UTF-8"
  2. $ echo 'aöæaæaæa' | tool -utf8 'æa'
  3. 2
  4. 4
  5. 6
  6.      
  7. $ export LANG="en_US.UTF-8"
  8. $ echo 'aöæaæaæa' | tool 'æa'
  9. 3
  10. 6
  11. 9
  12.      
  13. echo 'aöæææ' | awk '
  14. {
  15.   split($0, chars, "")
  16.   for (i=1; i <= length($0); i++) {
  17.     if ( chars[i] == "æ") print i-1
  18.   }
  19. }'
  20.      
  21. charLoc() {
  22.   [ "$#" -lt 2 ] && { printf 'insufficient argumentsn' >&2 ; return 1;  }
  23.  
  24.   printf '%s' "$1" | awk -v arg="$2" '
  25.   {
  26.     split($0, chars, "")
  27.     for (i=1; i <= length($0); i++) {
  28.       if ( chars[i] == arg) print i-1
  29.     }
  30.   }'
  31. }
  32.      
  33. charLoc 'aöæææ' "æ"
  34. 2
  35. 3
  36. 4
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top