Since wildcards aren't recognized by the GUI, is there another way?
-
1Use an online dictionary that supports wildcards: https://www.onelook.com– user3439894Jul 21, 2017 at 23:31
-
I should have added: I need to do this offline.– user192280Aug 2, 2017 at 12:16
4 Answers
From the command line you can use look
which looks for the string as a prefix of a word in the file- /usr/share/dict/words
.
look ent
Right click the word in the Terminal window and select Look Up "....." menu or you can grep
/usr/share/dict/words
using regular expressions or extended regular expressions. Such as:
grep 'hello$' /usr/share/dict/words
I never liked that the Dictionary.app in macOS does not support wildcards and while I mentioned in my comment to the OP to use and online dictionary that supports wildcards, I also searched Google for a third-party app that could be installed and didn't find any.
While one can easily bookmark the https://www.onelook.com URL, nonetheless, I decided to appify it, using AppleScript, saving it as Wildcard Dictionary Search.app, so I could access it from the Dock or Spotlight, etc.
Copy and paste the AppleScript code below into a new blank Script Editor document and save it as an application.
on run
try
tell current application
activate
set theSearchString to text returned of ¬
(display dialog ¬
"Wildcard Dictionary Search:" default answer "" buttons {"Cancel", "OK"} ¬
default button 2 with title "https://www.onelook.com/?w=")
end tell
tell application "Safari"
tell front window
if theSearchString is not equal to "" then
set current tab to (make new tab with properties ¬
{URL:"https://www.onelook.com/?w=" & theSearchString})
else
set current tab to (make new tab with properties ¬
{URL:"https://www.onelook.com"})
end if
end tell
end tell
on error eStr number eNum
if eNum is not equal to -128 then
display dialog eStr & " number " & eNum buttons {"OK"} ¬
default button 1 with icon caution
return
end if
end try
end run
Note that you can give it a custom icon and there are instructions on the Internet how to do that. I took the Dictionary.icns file from within the Dictionary.app, which is red, and using Preview to exported the 1024x1024 image as a PNG. I changed it to blue in GIMP by adjusting the Hue-Saturation on the red color. Then using instructions in Create Your Own Custom Icons in OS X 10.7.5 or Later I created a blue Dictionary.icns file, which I used to replace the applet.icns file within the AppleScript app, renaming it applet.icns.
-
My fault for not mentioning I need offline.– user192280Aug 2, 2017 at 12:19
Use egrep
command in Terminal
. It recognizes wildcards:
egrep "^..arl$" /usr/share/dict/words
The caret ^
tells egrep
command to search for the string at the beginning of a line, and the dot .
matches any character except a new line.
So, here are the results of a search:
gnarl
pearl
quarl
snarl
wharl
By using a question mark ?
you can even find words that may or may not have a characters:
egrep "^int..?$" /usr/share/dict/words
Result (here's into
included):
inter
intil
into
intue
Also you can use this bash alias
:
findword () { /usr/bin/grep ^"$@"$ /usr/share/dict/words ; }
findword '.ello'
Result:
cello
hello
Or you can search using *
for all words ending in mill
(including the word mill
itself):
egrep '^.*mill$' /usr/share/dict/words
crabmill
crazingmill
graymill
gristmill
mill
overmill
pugmill
remill
sawmill
semimill
treadmill
walkmill
windmill
-
1Not sure why this answer got down votes.– user192280Aug 2, 2017 at 12:17
-
I think the same. I sure it's right answer))– user243793Aug 2, 2017 at 12:29