TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Bash one-liner to produce a list of HEX color codes that read like English words

199 pointsby ailefover 2 years ago

20 comments

kragenover 2 years ago
I tried this a few years ago; <a href="http:&#x2F;&#x2F;canonical.org&#x2F;~kragen&#x2F;sw&#x2F;dev3&#x2F;colors.html" rel="nofollow">http:&#x2F;&#x2F;canonical.org&#x2F;~kragen&#x2F;sw&#x2F;dev3&#x2F;colors.html</a> has them as foreground colors and <a href="http:&#x2F;&#x2F;canonical.org&#x2F;~kragen&#x2F;sw&#x2F;dev3&#x2F;colors.2.html" rel="nofollow">http:&#x2F;&#x2F;canonical.org&#x2F;~kragen&#x2F;sw&#x2F;dev3&#x2F;colors.2.html</a> has them as background colors. I tested 3-letter words as well as 6-letter words, and used 1 as &quot;l&quot; as well as &quot;I&quot;, but I didn&#x27;t try aghasemi&#x27;s very productive suggestion of using 5 as S. I don&#x27;t remember if it it didn&#x27;t occur to me or if I tried it and didn&#x27;t like the results.<p>Some of them are pretty #bad (#011 doesn&#x27;t really look much like &quot;oil&quot;) and some, though they read quite well, correspond to awful colors; you might even say, #faeca1 colors. Still, I&#x27;ve made my #bed, #0dd as it may be; now I must #11e in it. I think I&#x27;ve #fed you enough #babb1e for today.
js2over 2 years ago
The gist is rather a pipeline of Unix commands with no bash necessarily involved. Here it is in shellcheck-compliant 100% bash:<p><pre><code> #!&#x2F;usr&#x2F;bin&#x2F;env bash shopt -s nocasematch while read -r word; do if [[ $word =~ ^[abcdefoi]{6,6}$ ]]; then word=${word&#x2F;&#x2F;o&#x2F;0} word=${word&#x2F;&#x2F;i&#x2F;1} word=${word^^} printf &#x27;#%s\n&#x27; &quot;$word&quot; fi done &lt; &#x2F;usr&#x2F;share&#x2F;dict&#x2F;words </code></pre> This could be collapsed to one line with semicolons. On the macOS 12.6 dictionary I get 59 words.<p>Edit: and in sed which someone just asked me for elsewhere:<p><pre><code> sed -n -e &#x27; &#x2F;^[abcdefoi]\{6,6\}$&#x2F;I { s&#x2F;o&#x2F;0&#x2F;g; s&#x2F;i&#x2F;1&#x2F;g; s&#x2F;^&#x2F;#&#x2F;; y&#x2F;abcdef&#x2F;ABCDEF&#x2F;; p;}&#x27; &lt; &#x2F;usr&#x2F;share&#x2F;dict&#x2F;words</code></pre>
评论 #33052245 未加载
评论 #33051326 未加载
nine_kover 2 years ago
Never mind the colors.<p>This snippet demonstrates how a number of small tools, each doing its narrow job, strung together via the most trivial interface, produces a non-trivial result.<p>This composability is still unreachable to the vast majority of GUI tools.
评论 #33050595 未加载
评论 #33050495 未加载
评论 #33050977 未加载
评论 #33050383 未加载
评论 #33050399 未加载
pwpwpover 2 years ago
It&#x27;s missing #DADB0D
评论 #33049529 未加载
评论 #33051610 未加载
b800hover 2 years ago
Is HEX another of these words which gets erroneously capitalised, like SCRUM or GAP analysis?
评论 #33052911 未加载
评论 #33054425 未加载
Waterluvianover 2 years ago
Does anyone have a link to a guide on how to write Python or node or rust programs that behave well with bash? Ie. Streaming inputs and outputs and other things I probably don’t know about?
评论 #33050109 未加载
评论 #33053339 未加载
评论 #33051041 未加载
评论 #33051308 未加载
评论 #33049814 未加载
netuleover 2 years ago
Reminds me of debugging pointer values in C with 0xDEADBEEF.
dwheelerover 2 years ago
I appreciate the presence of #C0FFEE.<p>Can&#x27;t do computing without that!! :-)
评论 #33050991 未加载
brrrrrmover 2 years ago
Similarly, a list of hex words <a href="https:&#x2F;&#x2F;jott.live&#x2F;code&#x2F;hex_words" rel="nofollow">https:&#x2F;&#x2F;jott.live&#x2F;code&#x2F;hex_words</a>
silisiliover 2 years ago
Fun idea. Perhaps could stretch a little like we did in calculators and add 5 for S, or even 7 for T, but that would likely be a bit less readable.
评论 #33049404 未加载
评论 #33050479 未加载
Yenrabbitover 2 years ago
It makes me happy that #ACAC1A is about the right colour for the flowers of the sweet acacia tree (a pale yellow).
dspillettover 2 years ago
I know this is only looking at single words, so would miss this, but I always like to work ABAD1DEA into PoC work.
评论 #33051135 未加载
1vuio0pswjnm7over 2 years ago
Not sure why this is being called &quot;Bash&quot; one-liner. It will work with many shells. It will run noticeably faster in Dash, for example. Test it yourself. Linux chooses Dash for non-interactive use, like this one-line script, because it is faster than Bash.
评论 #33052671 未加载
评论 #33051933 未加载
ratsmackover 2 years ago
I don&#x27;t like using multiple commands.<p><pre><code> mawk &#x27;BEGIN{b = &quot;[abcdefois]&quot;; l = &quot;[a-z]&quot;; W = &quot;^&quot; b l l l l l &quot;$&quot;}; $0 ~ W {print &quot;#&quot; toupper($0);}&#x27; &#x2F;usr&#x2F;share&#x2F;dict&#x2F;words</code></pre>
评论 #33050491 未加载
评论 #33051008 未加载
评论 #33050456 未加载
kgwxdover 2 years ago
I wanted a t-shirt that is the color #FAB; and says #FAB; on it, thought it&#x27;d be a fun one for digital artists, then I found out how hard it would be to get t-shirt that matches it just right.
teaearlgraycoldover 2 years ago
Fun fact: Every Java .class file starts with the magic bytes C0FEBABE
评论 #33049423 未加载
评论 #33049420 未加载
cantSpellSoberover 2 years ago
Similar: <a href="https:&#x2F;&#x2F;nedbatchelder.com&#x2F;text&#x2F;hexwords.html" rel="nofollow">https:&#x2F;&#x2F;nedbatchelder.com&#x2F;text&#x2F;hexwords.html</a>
nick0garveyover 2 years ago
Interesting one liner but would like to see the colors it generates
评论 #33052321 未加载
评论 #33051035 未加载
评论 #33050696 未加载
评论 #33050301 未加载
评论 #33049666 未加载
pushedxover 2 years ago
What about 7 for T and also 3 for E?
评论 #33054533 未加载
IgorPartolaover 2 years ago
No 7 for a T?