4 ms·
Replaces the current day of the month with []: $ cal | sed "s/.*/ & /;s/ $(date +%e) / [] /" September 2013 Su Mo Tu We Th Fr Sa 1 2
by grimgrin 13y ago
Replaces the current day of the month with []:
$ cal | sed "s/.*/ & /;s/ $(date +%e) / [] /"
September 2013
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 [] 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
- res0nat0r 13y agoGcal will highlight the current date for you. http://www.gnu.org/software/gcal/ http://www.gnu.org/software/gcal/
- nawitus 13y agoHmm, the day is already highlighted for me (inverted color).
- ape4 13y agoYou can turn that off with: cal | cat
- aeon10 13y agocan you please explain how this works?
- shabble 13y agoit's quite a common pattern in commandline apps to check if the stdout is a tty or not, and do things differently if so. So when you pipe it through `cat', it does the no-fancy-included output, much like the colouring that `ls' will apply interactively, but not when piped/redirected.
- ajuc 13y agoIt's important for grepping and sedding - the colors are escape codes and would mess with your regular expressions otherwise (you want to find foobar , but bar was blue so you got foo\e[1;34mbar\e[0m instead, and it doesn't match with foobar).
- jlgreco 13y agoOn the other hand, if you want colors displayed you can force grep/ack to display the color 'always' and then pipe the output into 'less -R'. The -R (or --RAW-CONTROL-CHARS) flag has less display output such that color escape sequences work as you might expect, coloring the output displayed by less.
- jasomill 13y agols | cat is also useful because it forces single-column output.
- caw 13y agoIsn't that the same as ls -1?
- gpvos 13y agoMostly, yes, except that ls -1 does not turn off colours, and maybe there are a few more differences.
- Ziomislaw 13y agoI can't imagine why anyone would want to spawn another process instead of just RTFM, if you are on linux: ls --color=never -1
- oneeyedpigeon 13y agoBecause, in many - if not most - situations, spawning another process is insanely lightweight compared to the cognitive/physical load of your alternative (which includes remembering the switch and its value ("never" is hardly intuitive), remembering whether or not you're using a system that supports it (surprise, surprise, OSX doesn't), and typing all those extra characters). 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.
- syncsynchalt 13y agoYou are Randal L. Schwartz and I claim my five pounds. [http://partmaps.org/era/unix/award.html http://partmaps.org/era/unix/award.html]
- prakashk 13y agoColor output is not on by default in 'ls'. Your 'ls' must be an alias for the real ls with some options. For example, mine is: $ type ls ls is aliased to `ls --color=auto' A quick way to run the original 'ls' (not the aliased version), just prefix it with backslash: $ \ls ... Or: $ command ls ...
- grimgrin 13y agoIt appears that on OS X 10.6 cal is from 2004, and on Ubuntu it's a 2009 build. The 2009 build highlights the day of the month.