2009-04-30

 

Bash scripts and directory names with spaces

As a rule I avoid directory names with spaces, but from time to time you have to deal with these oddities in your bash scripts. Here is a quick script that demonstrates how to work around this problem...

To test, create a directory like "/tmp/some dir". Change into this directory and run the script. You should see something like this:


1 $ /tmp/test.sh
2 Attempting to go back to '/tmp/some dir'
3 /tmp/test.sh: line 6: cd: /tmp/some: No such file or directory
4 /tmp/some dir
5 DONE


As you can see, it breaks at line 3. Here is the script:

 
1 #!/bin/bash
2
3 HERE=`pwd`
4 cd /tmp
5 echo "Attempting to go back to '$HERE'"
6 cd $HERE
7 if [ $? -gt 0 ]
8 then
9 cd "$HERE"
10 if [ $? -gt 0 ]
11 then
12 echo "FAILED"
13 fi
14 fi
15 pwd
16 echo DONE


The trick lies in line 9 - using quotes :-)

2009-04-13

 

URL Shortening - Problems and solutions

Background read to understand the problem: http://joshua.schachter.org/2009/04/on-url-shorteners.html

Some of the main problems for web users:


On the site owner side there is a big question as to how search engines deal with the issue. Most search engines use some popularity algorithm to calculate which site is more popular in any given search scenario. The problem is that your site might be very popular, but since the URL points to a URL shortening service some search engines (maybe all of them) might not make the connection and your site popularity on the given search engines take a nose dive.

Is there a solution?

It looks like it... Still early days, but have a look at these two articles:

  1. http://shiflett.org/blog/2009/apr/save-the-internet-with-rev-canonical
  2. http://laughingmeme.org/2009/04/03/url-shortening-hinting/

Other resources:

  1. http://revcanonical.appspot.com/
  2. http://revcanonical.wordpress.com/

2009-04-10

 

New playlist

On Youtube I created a play list of the three parts about the Toyota Hilux that To Gear tried to "expire" - but failed... Brilliant series...




You can also try this link if the above embedded object doesn't work...

2009-04-02

 

Easily mirror a site with wget

$ wget -nv -t 0 -c -nc -4 -x -nH --user-agent="" -r -l 5 -k -p -np http://site/path/

For those like me that can never remember :-)

This page is powered by Blogger. Isn't yours?