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:
This is just a slight alternative that wraps all of #7917 in a function that can be executed
There are 3 alternatives - 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.
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 :-)
If you can do better, submit your command here.
You must be signed in to comment.