How can I either create or find a list of 3-letter unix commands on Mac OS X?

I'd like to create a new program/command for a project. I'd like to make it a 3-letter name, but I don't want to conflict with other unix commands. I am interested in seeing what is available before I settle on a particular name.

  • 1
    Pick your app name then Google "manpage <URNAME>" if theres a manpage for that combination change it. – Rhyuk Jul 13 '12 at 17:25
  • I'm interested in seeing my options before picking a name though. – Kyle Tolle Jul 13 '12 at 17:34
  • I would agree - picking a name that makes sense and then checking for and adjusting to work around conflicts seems like a better way to not confuse your user than just starting out with all of the TLA namespace not already taken. – jw013 Jul 13 '12 at 20:19

Try this

compgen -A function -abck | awk 'length($0) == 3'

(edit: its a bash builtin, so you should execute it in bash, and it will immediately give you the list of 3 char commands)

  • Chosen for its simplicity. – Kyle Tolle Jul 14 '12 at 0:38

Quick and dirty method, iterating over PATH and checking each directory. Make sure your $PATH is something sensible before running.

for dir in $PATH; do
        for file in "$dir"/???; do # ??? for 3 letter name
                if [ -x "$file" ]; then
                        printf %s\\n "$file"
  • printf is a little excessive for that task, innit? Why not echo? – Warren Young Jul 13 '12 at 18:15
  • 2
    Why not echo? Just personal habit of never passing variable strings to echo, since echo is extremely non portable when passed arguments that look like options or contain backslashes. In this case echo would probably be fine because on any reasonable system the first character of $dir would be /, although the path could still contain `, so printf` is still better. How is it excessive? I hardly think the difference in efficiency matters for this task. The few extra characters of typing save me the brain cycles of determining when passing variables directly to echo is safe. – jw013 Jul 13 '12 at 18:31
  • This didn't seem to work for me. I tried to echo $IFS and got an empty string. – Kyle Tolle Jul 13 '12 at 18:34
  • 2
    @WarrenYoung: printf is more flexible, and much more consistent, than echo. I agree that echo would almost certainly work fine in this case. Both echo and printf are built-in commands, at least in bash. – Keith Thompson Jul 13 '12 at 20:43
  • 2
    I'd pipe the output through something like sed 's,.*/,,' | sort -u to remove the directory names and strip duplicates, and then perhaps through fmt so the output fits on my screen. – Keith Thompson Jul 13 '12 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.