TL;DR: man ascii, cal, xxd, ssh, mdfind
`mdfind' in non-Mac UNIXs is spelled `locate' (and the corresponding `updatedb' updates the indexing db, obviously (although you don't have to do this often, as it runs as a cron job)).
Unix Commands I Wish I’d Discovered Years Earlier
111–120 of 259 posts
Re: Unix Commands I Wish I’d Discovered Years Earlier
#112I want a command that counts files in a tree like du does sizes but without having to pipe find through wc which is crazy for hundred thousand files. Can't they just directly access inodes for high speed counting?
If your locatedb is current, you can use locate for this:
$ locate $PWD | wc -l
That runs in just a hair under a second (0.908s real) for the first instance. 'find' takes a few seconds on first pass (it's got to read from disk), but is surprising fast (0.227s real) on subsequent runs.So I guess it depends on whether you're doing it just once or multiple times.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#113If anyone is interested there were several great posts on Hacker News a while about about useful UNIX commands [1, 2, 3]. I have also created several screencasts about command commands like the following [4], and one about the Filesystem Hierarchy Standard [5]. ls man pwd cd top ps df du cp mv rm mkdir rmdir less cat vi [1] https://news.ycombinator.com/item?id=6046682 [2] https://news.ycombinator.com/item?id=5022457…
Great links, though I admit when I saw the OP I was expecting content like that and was pleasantly surprised that they really were "Unix commands I wish I'd discovered years earlier", and not the standard array of unix tips+tricks that you can get by without for awhile but as you become more advanced become second-nature. "Man ascii." The number of times that I wound up generating my own ascii table from whatever lan…
You reminded me of something. There is actually a really cool and simple site called asciiflow [1], which I use all the time to draw diagrams for explaining things in email, etc. It's pretty cool, and was even submitted several times to HN [2, 3].
[1] http://www.asciiflow.com/#Draw
Re: Unix Commands I Wish I’d Discovered Years Earlier
#114I believe xxd is actually part of vim and not a Unix command itself. It's used to support hex-editing binary files, but you can see why it's useful in other roles as well.
The origins of xxd seem to be a bit murky, as I've seen others say the same thing about xxd being available only if vim is installed, but I've never seen a Unix system that didn't have vi(m) included. $ man xxd | grep vi Use xxd as a filter within an editor such as vim(1) to hexdump a region Use xxd as a filter within an editor such as vim(1) to recover a binary Use xxd as a filter within an editor such as vim(1) to…
Re: Unix Commands I Wish I’d Discovered Years Earlier
#115Re: Unix Commands I Wish I’d Discovered Years Earlier
#116It will also provide encodings for single characters: $ ascii a ASCII 6/1 is decimal 097, hex 61, octal 141, bits 01100001: prints as `a' Official name: Miniscule a Other names: Small a, Lowercase a
ASCII 0/10 is decimal 010, hex 0a, octal 012, bits 00001010: called ^J, LF, NL
Official name: Line Feed
Other names: Newline, \nRe: Unix Commands I Wish I’d Discovered Years Earlier
#117I recently discovered whatis and I love it.
Yup, it's a great way to review a lot of commands without reading every man page. Want to find all the tools on your system that use the curses library (for user-friendly interfaces)? Try this: for i in `\ls /bin/* /sbin/* /usr/bin/* /usr/sbin/* | sort -u` ; do ldd $i 2>/dev/null | grep -q curses && whatis `basename $i` ; done | grep -v 'nothing appropriate' Don't know how your current path finds a program? Use which…
> where ls
ls: aliased to ls --color=tty
/usr/bin/ls
/bin/lsRe: Unix Commands I Wish I’d Discovered Years Earlier
#118One of the more useful bits of ssh is not mentioned: remotely running commands. Example: ssh username@host "echo $HOSTNAME && sudo somecommand && cat somecommand.log" There's probably a better way to do this, but in a pinch I can fix a problem on dozens of machines just by altering the host string.
'screen' is absolutely crucial with ssh, too.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#119Rather than 'man 7 ascii', there's the 'ascii' command itself. It will also provide encodings for single characters: $ ascii a ASCII 6/1 is decimal 097, hex 61, octal 141, bits 01100001: prints as `a' Official name: Miniscule a Other names: Small a, Lowercase a ASCII 0/10 is decimal 010, hex 0a, octal 012, bits 00001010: called ^J, LF, NL Official name: Line Feed Other names: Newline, \n
Re: Unix Commands I Wish I’d Discovered Years Earlier
#120ctrl-R in bash was mine.
set -o vi
it's awesome