1,089 karma · joined March 1, 2007
C, Unix system and shell, Python, X Windows, ARM, ...
export PAGER=less LESS='-wiXz-2$j15' LESSBINFMT=.My preference is Kernighan and Pike's _The Practice of Programming_, TPoP, that's Kernighan as in the `k' in awk and K&R, and Pike as in Blit, sam, and now #golang. The book's home page has a sample chapter and a war story that didn't make it into the book. http://amazon.com/exec/obidos/ASIN/020161586X/mqq-20 http://cm.bell-labs.com/cm/cs/tpop/
If sort, tai64nlocal, and ffmpeg are all happy to read stdin so you can do
cat foo | sort ...
cat foo | tai64nlocal ...
cat foo | ffmpeg ...
then they can all have their stdin redirected instead by the shell: <foo sort ...
Similarly with stdout: ... | sort | cat >foo
becomes ... | sort >foo
In both cases regularity of having the filename at the start and end is preserved. <foo sort | ...
is an alternative to cat foo | sort | ...
though I wouldn't particularly recommend it. Instead the overhead of cat(1) should be omitted and it written in the normally accepted form of sort foo | ...
Providing a filename rather than re-directing stdin allows the program more choice over its method of access.You may want to peruse Aho and Ullman's excellent C edition of Foundations of Computer Science. (That's Aho as in awk.) What you need for a good grounding all in one place. You can still pick up a paper edition if you want but they've also made it available as PDFs.
http://amazon.com/exec/obidos/ASIN/0716782847/mqq-20 http://i.stanford.edu/~ullman/focs.html
$ sudo -i
# tr \\0 \\n </proc/$$/cmdline
-bash
# def wrap_around(self):
"""Change the position of the bubble to toroidally
"wrap around" if it goes off one edge of the
map."""
if self.pos.x < 0: self.pos.x += 1
if self.pos.y < 0: self.pos.y += 1
if self.pos.x > 1: self.pos.x -= 1
if self.pos.y > 1: self.pos.y -= 1
Why isn't else used? In addition to efficiency it tells the reader that the author expects at most one of x++ or x-- to happen. find -type f -exec ls -ltr {} +It doesn't work for me, the hotspot isn't listed on the Nexus among the many local networks, and without other wifi equipment I'm unsure where the fault may lie; so many possibilities.
#! /bin/sh
exec egrep --color "$@"
(Not a bash, my shell, alias because they're unavailable in many contexts.)egrep is AKA grep -e. I don't use GREP_OPTIONS because it pollutes those that don't expect it, as you pointed out.
At the top of a particular source tree I may have a ./g that knows more about what's interesting.
#! /bin/bash
find \( -name .svn -o -name tags \) -prune -o -type f -exec egrep "$@" {} +
It checks -name before -type because the latter needs a stat(2).For other things I do ad hoc queries using grep, find, xargs, etc.
(Edited to use ✳ to workaround unescapable mark-up.)