Live data from Hacker News

Unix Commands I Wish I’d Discovered Years Earlier

spin.atomicobject.com

111–120 of 259 posts

Re: Unix Commands I Wish I’d Discovered Years Earlier

#111
post #14

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)).

mdfind is incomparably more powerful than locate.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#112
post #6

I 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?

It's not the pipe through wc, but statting the directory entries which slows you down.

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

#113

If 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…

re: ascii tables

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

[2] https://news.ycombinator.com/item?id=2847177

[3] https://news.ycombinator.com/item?id=3598177

Re: Unix Commands I Wish I’d Discovered Years Earlier

#114
post #53
post #18

I 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…

There are no hits for xxd on the Unix Tree (http://minnie.tuhs.org/cgi-bin/utree.pl) so it's definitely not a traditional Unix tool. I'm sitting in front of a BSD system which includes nvi. I don't have xxd.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#116
Rather 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

#117
post #20

I 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…

The zsh builtin 'where' is pretty good too:

  > where ls
  ls: aliased to ls --color=tty
  /usr/bin/ls
  /bin/ls

Re: Unix Commands I Wish I’d Discovered Years Earlier

#118
post #28

One 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.

I find tmux to be a bit more pleasant to work with. In the past it didn't do reflowing upon resize, but it does that now.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#119

Rather 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

Which Unix includes that command?
Post reply on HN