commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Are the two strings anagrams of one another?
sed splits up the strings into one character per line
the result is sorted
cmp compares the results
Note: This is not pretty. I just wanted to see if I could do it in bash.
Note: It uses fewer characters than the perl version :-)
There is 1 alternative - vote for the best!
This works by reading in two lines of input, turning each into a list of one-character matches that are sorted and compared.
This is just a slight alternative that wraps all of #7917 in a function that can be executed
If you can do better, submit your command here.
You must be signed in to comment.