Hi,
But for disk images, memory cards and USB sticks, it displays as Ki and Mi instead of Mb and Kb, how can I change this?
Code:
sed 's/<blah>/<blah>/<some option>'
finds regular expressions (You can google this and learn all about it, super duper useful stuff) in the first blah, and replaces them with the second blah. So another way to do this would be
So the s says replace the first thing with the second thing. The "/" says this is the thing I want to replace. The \( says, hey, remember this part, I want to use it later. The [GMK] says look for anything that starts with a G, M, K. the \) says, hey we're done saving. And the the "i" completes the experession. The next "/" says hey, here's the thing to replace with. The \1 says, Hey remember that thing I wanted you to save? Well use it here. Then the b, just completes the replacement. Then the / says, ok we're done replacing. The trailing g says, do this more than once per line.
So in summarry \([GMK]\)i finds characters that look like Gi, Mi, Ki and saves the G, M, and K for later use via \1. And the general form of a search and replace sed command is 's/<thing to replace>/<replacement>/<flags>.
P.S. Googling sed one-liners gives a website that is worth it's weight in gold.
but the current day shows as ## instead of being highlighted??
Well if we look at your experession...
Code:
cal | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/./#/g') /
There are multiple search and replaces is going on here.
The first one adds a space to the beginning of each line (^ is regular expression for begging of the line)
The second one adds a space to the end of each line ($ is a regular expression for end of line)
The third experession has two expressions so lets start on the inside. date +%e returns the date for example today it would be 26. However, if the date were 1, it would return 1 instead of 01 (date +%d will return 01). Now the "|" character sends the output of the date command to our sed command. In our sed command "." will match anything, it is the single character wild card. So this replaces every character in the date command with a #. The $( ) says, hey evaluate this first, and then stick it in.
Code:
$(date +%e | sed 's/./#/g')
Now in the outer sed command, we search for the current date, and replace it with the #'s that we get from the inner sed command.
Code:
s/ $(date +%e) / $(date +%e | sed 's/./#/g') /
which will evaluate to
So you can see why you are getting the ## in there. Unfortunately, I believe geektool does it's own font formatting, so I don't think there is a way to leave the number and simply highlight it. I think even if you do this, geektool will just override it anyway.
Hopefully that wasn't too much overload, and will help you better understand what your geek tool scripts are doing. Also geektool is simply running bash commands, so if you want to learn more about this you can google bash scripting guide and you'll get a great guide that will teach all kinds of wonderful things.