Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ export LANG="en_US.UTF-8"
- $ echo 'aöæaæaæa' | tool -utf8 'æa'
- 2
- 4
- 6
- $ export LANG="en_US.UTF-8"
- $ echo 'aöæaæaæa' | tool 'æa'
- 3
- 6
- 9
- echo 'aöæææ' | awk '
- {
- split($0, chars, "")
- for (i=1; i <= length($0); i++) {
- if ( chars[i] == "æ") print i-1
- }
- }'
- charLoc() {
- [ "$#" -lt 2 ] && { printf 'insufficient argumentsn' >&2 ; return 1; }
- printf '%s' "$1" | awk -v arg="$2" '
- {
- split($0, chars, "")
- for (i=1; i <= length($0); i++) {
- if ( chars[i] == arg) print i-1
- }
- }'
- }
- charLoc 'aöæææ' "æ"
- 2
- 3
- 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement