Earlier quoted context omitted.
You should do a screencast of such infinitely useful classics as tac , tsort , and sl . (Actually, I have found use for those first two on occasion. ;)
Thanks for the suggestion! Actually, I initially wanted to do one on more advanced commands, but I thought I'd better lay a foundation first. I also want to cover using pipe (|) to chain these commands together. I'll make sure to include these.
Unix Commands I Wish I’d Discovered Years Earlier
231–240 of 259 posts
Re: Unix Commands I Wish I’d Discovered Years Earlier
#232When do you need man ascii and xxd? I'm a front-end developer so I have no clue about these low-level things but I'm interested and would like to learn.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#233Earlier quoted context omitted.
I am not saying find is outputting files, I am saying it is decoding the full table entry for each file and formatting it, then passing that listing as an entry to wc. Which has to be a bunch of overhead that adds up when you have hundreds of thousands of files to count. All we want from find is "count the number of inode entries in this tree branch that are type f". No formatting, no output, just count. That has to…
OMM, looking at 700k files on a spinning disk, I'm getting an uncached run at 1m13s, and a cached run at 1.2 seconds. That's "time find . | wc -l" It's going to be disk limited unless you're in cache. Switching to "time find . -printf '1' | wc -c" lowers overhead to .7 seconds, so roughly 1us/file.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#234Earlier quoted context omitted.
Right, you can use this to easily find the number of days in an arbitrary month in a script: % cal 2 1972 | tail +3 | wc -w 29
tail: cannot open +3 for reading: No such file or directory What am I doing wrong? This worked like a charm though: cal dec 2002 | tail -6 | wc -w (since it always takes up 6 lines, even sep 1752)
On older systems, the leading '-' can be replaced by '+' in the obsolete option syntax with the same meaning as in counts, and obsolete usage overrides normal usage when the two conflict. This obsolete behavior can be enabled or disabled with the '_POSIX2_VERSION' environment variable (*note Standards conformance::).Re: Unix Commands I Wish I’d Discovered Years Earlier
#235I 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…
I'm a bit more tolerant of vi now, but just because I "never" see it courtesy of suitable EDITOR entries.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#236Earlier quoted context omitted.
Isn't that the same as ls -1 ?
Mostly, yes, except that ls -1 does not turn off colours, and maybe there are a few more differences.
ls --color=never -1Re: Unix Commands I Wish I’d Discovered Years Earlier
#237Re: Unix Commands I Wish I’d Discovered Years Earlier
#238Earlier quoted context omitted.
Mostly, yes, except that ls -1 does not turn off colours, and maybe there are a few more differences.
I can't imagine why anyone would want to spawn another process instead of just RTFM, if you are on linux: ls --color=never -1
Admittedly, I never actually do this because I don't ever care to not see colour (what would be the motive?), but I can understand why the OP does what they do.
Re: Unix Commands I Wish I’d Discovered Years Earlier
#239Earlier quoted context omitted.
Mostly, yes, except that ls -1 does not turn off colours, and maybe there are a few more differences.
I can't imagine why anyone would want to spawn another process instead of just RTFM, if you are on linux: ls --color=never -1
Re: Unix Commands I Wish I’d Discovered Years Earlier
#240Earlier quoted context omitted.
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