7 ms·
Ask HN: Why are there so few single-letter command line utilities / tools?
Is there a reason for so few single-letter command line utilities? On my macOS, running
for char in {A..z}; do type "$char" 2>/dev/null; done
gives the following
A not found
B not found
C not found
D not found
E not found
F not found
G not found
H not found
I not found
J not found
K not found
L not found
M not found
N not found
O not found
P not found
Q not found
R not found
S not found
T not found
U not found
V not found
W is /usr/bin/W
X not found
Y not found
Z not found
[ is a shell builtin
\ not found
] not found
^ not found
_ not found
` not found
a not found
b not found
c not found
d not found
e not found
f not found
g not found
h not found
i not found
j not found
k not found
l not found
m not found
n not found
o not found
p not found
q not found
r is a shell builtin
s not found
t not found
u not found
v not found
w is /usr/bin/w
x not found
y not found
z not found
Single letters are so much easier to type than any other number of letters. Curious if perhaps this was not allowed or was not possible for some reason in the earlier unix / linux days?
- pkrotich 5y agoI guess you haven't received a lecture yet on naming programs or functions - here it goes - a) choose a word with meaning, b) avoid generic names and c) don't make your names too long or too short. I'm obviously being sarcastic - but on a serious note, that's what aliasing is for - e.g "alias l='ls -lah'"
- sh4un 5y agoFat fingering could be fatal.
- LinuxBender 5y agoThis happened by mistake once. OpenVMS allowed for command shortening vs completion so you could type h edit if you wanted help on the edit command instead of help edit. One OS update broke that logic and h became halt. The results were unpleasant for many especially given OpenVMS at the time was commonly used on many financial systems, telco systems, government systems and much more. It's been a while so I forgot exactly when this happened but those impacted won't forget the experience.
- dredmorbius 5y agoSeverely underrated comment.
- Flankk 5y agoLetters hold no meaning. The ls, mv, cp, rm commands are self-explanatory with only one extra letter.
- dmitriid 5y ago> commands are self-explanatory with only one extra letter. They really aren't :) If you came across them outside of the context in which you learned them, they mean nothing. Once you've learned them, only then do you know that they are contractions/abbreviations: ls is list, mv is move, cp is copy etc.
- Flankk 5y agoObviously a word without vowels is an abbreviation of sorts. The only context I had learning the shell was from using DOS. The equivalent would be DIR, MOVE, COPY, DEL. DOS sucked but I did enjoy playing Lemmings.
- dmitriid 5y agoWhen I moved to Linux from Windows I couldn't understand why the operations weren't actual words you could deduce and remember :) mv instead of move? why?! Now I have them internalised, so it's fine.
- TheMonarchist 5y agoUnix was created on a PDP-7. Two letters was generous considering that they had to use an electromechanical terminal. They also had only 4K words of store in the beginning so they wouldn't run out of meaningful shorthands.
- tmp538394722 5y ago“mv” - it stands for renaMe(v)
- poopypoopington 5y ago
- smoldesu 5y agoIf it really bothers you, it's easy enough to alias those letters to the commands that you do want, which is probably better for flexibility and whatnot. Adding in single-letter commands would probably be too hard to remember for most people.
- asicsp 5y agoAgreed. I use single letter aliases, for ex: h='history | tail -n20' l='ls -ltrhG' d='dict -d wn' s='du -sh * | sort -h'
- moehm 5y ago> s='du -sh * | sort -h' Quick shoutout, you should probably alias to 'du -sh -- *'. Otherwise file names starting with '-' are interpreted as input for your command.
- 0xJRS 5y agothose are good. While they arent a single char I do like these a lot: gs='git status' gl='git pull' gcm='git commit -m' ga='git add -A' gp='git push'
- asicsp 5y agoI have something similar too! gst='git status' ga='git add' gc='git commit -am' gl='git log --graph --pretty=format:"%h %Cred%s%Creset %Cgreen(%cr)%Creset" --abbrev-commit' glh='gl | head -n5' gp='git push'
- TeaVMFan 5y agoBecause they're impossible to search for. Tried researching a tool called 'a' once. Good tool, but hard to find docs.
- garmaine 5y agoI don’t think this is the answer, given that UNIX is from 1970. “man a” would have worked just fine.
- simtel20 5y agoI think that when the default c compiler turns source into an executable called "a.out", everyone is motivated away from "a". Having a compiler called "cc" renders "c" problatic. Similar arguments probably continue across the rest of the alphabet - the brevity only contributes to a lack of clarity. That's what shell functions and aliases let you do for a personal set of preferences.
- R0b0t1 5y agoNo one has the requisite hubris to seize a letter.
- jareklupinski 5y agojust a thought, maybe with early languages already taking up A, B, and C, folks thought of single letters as language domains? >"just use C" <"the program or the language?"
- sonofhans 5y agoI design a lot of CLIs, and I wonder this, too. I think it's two things. First, it's very hard to attach meaning to a single character. Many early Unix tools were two-character, which is just enough to remember and to be unique. Second, many (not all!) Unix people have been reluctant to pollute global namespaces. Anyone building a CLI tool for the use of others knows that it's going into a complex environment with many other tools. If it become commonplace to create single-letter tools than there would be constant conflict in that namespace. In my experience, groups of geeks are often aware of the tragedy of the commons, and able to act in concert against it.
- booboofixer 5y agoThat makes a lot of sense. I hope this thread doesn't give anybody any ideas.
- clavicat 5y agoI’ve always found the Unix preference for concision over descriptive and intuitive commands to be stupid. Even they feel that one-letter commands are too short—two letters are not much better.
- klyrs 5y agoSingle letters are reserved for variable names?
- majou 5y agoThis doesn't matter for shell, however reserving them for aliases is sensible.
- goodside 5y agoPlease appreciate you’ve just included a stderr paste enumerating all the letters of the alphabet in a question asking why anyone would use two letters when one would do.
- booboofixer 5y agoHa!
- ggm 5y agoPlease close this thread on 26 responses
- andy-x 5y agoI thought UNIX was case-sensitive from very beginning (though early terminals probably were not). Also digits/punctuation can be counted too, in fact '.' is a (shell) command.
- ggm 5y agoUntil very late in the piece if you logged in all-caps it flipped your terminal session over to an all caps login assuming you were on an ASR33 teletype. I think it dropped out after BSD4.3 -I did actually use this state. Nobody I know in my cohort/age-group thinks capital letters make a different command. Lots of us inherited a memetic state of alias/function to make a single "l" do some variant of the ls command. And "m" for more was not uncommon. "p" to pass to the large for some, never bothered me much to type more letters. Other than that, the "w" and . Are about it. . As an execution invitation feels less like a command than just syntactic suger. (As does the cryptic :> to zero instantiate a file)
- daveidol 5y agoCheck out “z” - I use it all the time: https://github.com/rupa/z https://github.com/rupa/z
- 112 5y agoIt's for the best, you can use them as names for your own stuff.
- cyberge99 5y agoI think a lot of people may use aliases invoked by a single letter. They’re very specific to each persons workflow, habits, etc.
- anotherhue 5y agoSeconded
- klysm 5y agoIt’s a small namespace, bad idea to pick something from a small occupied by everybody else making things too in the future and unbeknownst to you from the past
- beardyw 5y agoLet's put a positive spin on it. You can safely use all 26 to assign to your favourite commands.
- jaclaz 5y agoIn the (good ol') times of DOS, Qedit: https://en.wikipedia.org/wiki/The_SemWare_Editor#Qedit https://en.wikipedia.org/wiki/The_SemWare_Editor#Qedit was an almost ubiquitous text editor, the actual program was named q.exe, invoked by simply "q".
- peterkos 5y agoWhat I can say is that it lets me have a lot of convenient aliases for things that are 1 letter long: “o” for “open .”, “s” for “subl .”, etc. And nice 2 letter ones: “gc” for “git commit”.
- dredmorbius 5y agoFor the "why": - The namespace is small. Appropriating it for a specific command might well prove inconvenient later. - Critical commands in a single character could lead to ... undesired consequences. There's already sufficient risk with two- and three-letter commands. - Many commands are short, though 2--4 characters rather than 1. And finally: there are more single-letter commands than your one-liner would suggest. I think 'a' was the assembler on some systems. 'R' is a statistical application. It is the successor to 'S' 'X' is the X11 windowing system. It is the successor to 'W'. Not to be confused with 'w'. There are the A, B, C, and D programming languages, at a minimum. As others have noted, searching for them specifically (amongst other commands) is ... something of a pain.