Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ sh soundex.sh fissbux
- ./fizzbuzz
- ./fizzbuzz.c
- ./fizzbuzz2
- ./fizzbuzz2.c
- $ sh soundex.sh sharlok
- ./HackerRank/Algorithms/02-Implementation/17-sherlock_and_squares.c
- $ sh soundex.sh sundek
- ./soundex.sh
- ./soundex.sed
- #!/bin/sh
- soundex=$( printf '%sn' "$1" | tr 'a-z' 'A-Z' | sed -f soundex.sed )
- find . -exec sh -c '[ "$( printf '%sn' "${1##*/}" | tr 'a-z' 'A-Z' | sed -f soundex.sed )" = "$0" ]' "$soundex" {} ';' -print
- s/[^[:alpha:]]//g
- h
- s/^(.).*$/1/
- x
- y/bfpvBFPV/11111111/
- y/cgjkqsxzCGJKQSXZ/2222222222222222/
- y/dtDT/3333/
- y/lL/44/
- y/mnMN/5555/
- y/rR/66/
- s/([1-6])[hwHW]1/1/g
- s/([1-6])11*/1/g
- s/[aeiouyhwAEIOUYHW]/!/g
- s/^.//
- H
- x
- s/n//
- s/!//g
- s/^(....).*$/1/
- s/^(...)$/10/
- s/^(..)$/100/
- s/^(.)$/1000/
- # Remove non-alphabetic characters
- s/[^[:alpha:]]//g
- # STEP 1 (part 1: retain first character)
- # Save whole line in hold-space
- h
- # Delete everything but the first character and swap with hold-space
- s/^(.).*$/1/
- x
- # The hold-space now contains only the first character
- # STEP 2
- y/bfpvBFPV/11111111/
- y/cgjkqsxzCGJKQSXZ/2222222222222222/
- y/dtDT/3333/
- y/lL/44/
- y/mnMN/5555/
- y/rR/66/
- # STEP 3
- s/([1-6])[hwHW]1/1/g
- s/([1-6])11*/1/g
- # STEP 1 (part 2: remove vowels etc.)
- # We don't actually remove them but "mask" them with "!"
- # This avoids accidentally deleting the first character later
- s/[aeiouyhwAEIOUYHW]/!/g
- # Replace first character with the one saved in the hold-space
- # Delete first character
- s/^.//
- # Append pattern-space to hold-space and swap
- H
- x
- # Remove newline inserted by "H" above and all "!" (old vowels etc.)
- s/n//
- s/!//g
- # STEP 4
- s/^(....).*$/1/
- s/^(...)$/10/
- s/^(..)$/100/
- s/^(.)$/1000/
Add Comment
Please, Sign In to add comment