Random oneliners: Difference between revisions
From diffies' wiki
Jump to navigationJump to search
Created page with "Here I place some useful/interesting/silly oneliners – mostly in GNU bash and Perl. == List characters used in a file tree == This produces a neatly formatted listing of special characters in a given directory tree. (Note the slash, which is the path separator.) <syntaxhighlight lang="bash">find directory/ | fold -w1 | sort | uniq | fmt</syntaxhighlight> Example output: <pre>_ - @ / = 0 1 2 3 4 5 6 7 8 9 a A b B c C d D e E f F g G h H i j J l L m n N o p P q..." |
No edit summary |
||
| Line 5: | Line 5: | ||
This produces a neatly formatted listing of special characters in a given directory tree. (Note the slash, which is the path separator.) | This produces a neatly formatted listing of special characters in a given directory tree. (Note the slash, which is the path separator.) | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="shell">find directory/ | fold -w1 | sort | uniq | fmt</syntaxhighlight> | ||
Example output: | Example output: | ||
Revision as of 03:29, 16 October 2026
Here I place some useful/interesting/silly oneliners – mostly in GNU bash and Perl.
List characters used in a file tree
This produces a neatly formatted listing of special characters in a given directory tree. (Note the slash, which is the path separator.)
find directory/ | fold -w1 | sort | uniq | fmtExample output:
_ - @ / = 0 1 2 3 4 5 6 7 8 9 a A b B c C d D e E f F g G h H i j J l L m n N o p P q r R s S t u U v w x y Y
Note that this breaks for whitespace (ASCII space is rendered as a blank line at the beginning of the output) and control characters, not to mention Unicode.
Processing of a big filesystem trees can take a considerable time, as this dumb oneliner sorts the letters before deduplicating them.