Simple example: ls the user preferences folder, grep for some filename. I hope I did this correctly. I edit poorly.
# simple example, list user pref files, grep for names containing "midi"
ls -la1 $HOME/Library/Preferences/ |/usr/bin/grep --color=auto "midi"
# obligatory script pseudo-example
bla.sh "midi"
ls -la1 $HOME/Library/Preferences/ |/usr/bin/grep --color=auto "$*"
Note: less -r
or -R
??? Possible Mavericks likes less -R
but earlier OSX liked less -r
, maybe that is some emv stuff i did.*
less -R
will display ANSI colors, if you provide some! Grep color=always will push ANSI colors into less -R
. (references below). NOTE: I found -R better on Mavericks. And though the man page for less says -R would be better, I recall -R looked like crap on earlier OSX verions, where -r is seemed better.
# again, look for filename with "midi" in this folder
ls -la1 $HOME/Library/Preferences/ |/usr/bin/grep --color=always "midi" |less -R
# obligatory script pseudo-example
bla.sh "midi"
ls -la1 $HOME/Library/Preferences/ |/usr/bin/grep --color=always "$*" |less -R
- General info credit this superuser: [http://superuser.com/questions/117841/get-colors-in-less-command/117842#117842].
- And another superuser: [http://superuser.com/questions/36022/less-and-grep-getting-colored-results-when-using-a-pipe-from-grep-to-less/36045#36045].
Apparently, if using grep with --auto
or color=auto
post says "However, when it detects a pipe it disables coloring."
This gist is a personal reminder about this particular bash arcana. I forget simple crap like this because so many darn coding languages have quirks. I forget about them. Perhaps because I am not the "TechnoCore" (authors Dan Simmons, et al.) More probable, because I resemble the slow zone (Vernor Vinge book lingo).
So my solace is this: I am not a machine. -- But are you sure?
Any script could spit out this nonsense -- simple code examples and subsequent poorly assembled sophistry. More search bots will see this than any human, So who cares.
In the end, I go with the Dan Simmons's Keats cybrid's (perhaps) apocryphal citation of [Keats] 1, or some [later Yeates] 2, (I do not know for sure), to wit:
Things fall apart;
the centre cannot hold;
Mere anarchy is loosed upon the world,
The blood-dimmed tide is loosed,
and everywhere The ceremony of innocence is drowned;
The best lack all conviction,
while the worst Are full of passionate intensity.
Isn't that profound Who knows, it sounds cool, but states the obvious -- debugging code is the worst. Anarchy in any code is stupid, someone will file a bug report. People will hassle you to fix it. It's no fun. You should have written cleaner code -- obviously with PYTHON no doubt.
Geeks know better. Poets? What do they know of the horrors of Bugzilla, or the euphemistically entitled 'Issue Tracker.' Or of some corner case bug no one cares about, but some bonehead assigned you to fix it. Oh. OH, OH!!
Yes, this is sarcasm -- SARCASM! Frustration of bash!
But the code example should be a useful reminder.