Thursday, April 17, 2008

Actually... (aka Digital Recording II)

Assuming the background of this post, the amount of digital recording of other peoples' lives that I have through email, chats, journals, etc., is pretty amazing as well.

For anyone getting worried, save for the unfortunate of my untimely demise,* this is pretty much inaccessible to anyone but me. And even then it depends on my memory; my memory jogged by my own pictures, emails, chats, journals, writings (and blogs for that matter), etc.

Still, if you are one of the people that still read my blog, I probably have more of your life recorded than you realize. Of course, given how "digital I am," this goes two ways. Maybe more toward me than towards you (whoever you are, viz., my life has more digital recordings than most peoples'.)

*Untimely meaning before I am... old. In the most usual sense. E.g., before (or slightly before) I hit my expected lifespan. On the other hand, given the stunts that I have pulled I figure my expected lifespan is somewhere around 15, which I have obviously passed. Given that, I figure my new one is -- give or take -- 30.


Saturday, April 12, 2008

Stripping Down Filenames in Bash

I've seen these two questions asked multiple times and have both haunted me from time to time, so I thought I would provide some answers, although the second is rather rudimentary.

1. Stripping the path off of a file
How often have you needed only the filename, not the path that precedes it? Fortunately most Linux distros make it pretty easy to strip off with the basename command. E.g.,

user@host:~$ basename /etc/apache2/httpd.conf
httpd.conf


Note that if the path contains spaces you will need to enclose it in quotes or escape it:

#Escaping
user@host:~$ basename /home/madjon/youth\ room\ shots/local\ youth\ demographics.xls
local youth demographics.xls

#Quoting
user@host:~$ basename "/home/madjon/youth room shots/local youth demographics.xls"
local youth demographics.xls


2. Stripping the file extension
This takes some bash string manipulation which you can find all about at tldp. If we take httpd.conf again:

# First, assign the filename to a variable:
user@host:~$ f=/etc/apache2/httpd.conf
user@host:~$ echo $f
/etc/apache2/httpd.conf

#Next, strip out any string, starting from the end of $f that matches ".*"
user@host:~$ echo ${f%.*}
/etc/apache2/httpd


Note that the variable substitution (the curly brackets) doesn't have the $ inside it. E.g., the general syntax is:

VAR=whatever
echo ${VAR%.*}


If we want to put them together:

user@host:~$ f=/etc/apache2/httpd.conf
user@host:~$ f=`basename $f`
user@host:~$ echo $f
httpd.conf
user@host:~$ echo ${f%.*}
httpd


I'm sure that this could be accomplished easier with some regex and awk or sed, but all three of those are confusing to me; simple bash scripting makes much more sense to me. I hope this helps whomever.


Wednesday, April 9, 2008

The Digital Recording of My Life

Holy cow, it's late! I meant to be in bed nearly 45 minutes ago, but I had this post...

I've been working on a writing project for some time now, it was completely lost when my hard drive on my laptop died. Fortunately, the sources that I pulled most of it from (all my own original writing) still are around.

But I had to go and find these files again which have been scattered across several hard drives email, and multiple folders. What really struck me was that between the emails, my writing -- both homework and journals -- and blog entries, I have a pretty detailed record of my life, at least from the last 4-5 years. I may or may not be able to recover data further back than that, but it gets sparser at that point anyway.

It just is amazing how much of our lives are becoming self-recording without our even thinking about it...


Monday, April 7, 2008

Watching Bethel

I partially broke my system for completing time lapses, thus the break in them. At any rate, this is the most recent as of yesterday.

Also, I am hoping to actually start blog blogging again soon, at least at best as I can. I have at least one draft post on economics -- even if only one person reads it :-)