Bash script for editing the hosts file

I just read a post about local development in apache by Jesper Rasmussen and thought one thing was missing. I usually test my sites and applications locally with the real domain – to ensure that functionality based on the url works as expected. However this means editing the hosts file several times a day. Now [...]

November 4, 2009  Tags: , , ,   Posted in: Web development  One Comment

Converting Filenames to Lowercase with Bash

Once again I have a bash-oneliner. For some reason it is all I blog about at the moment.
I had an import script for importing demo files (in mp3 format) to a database used at Voicearchive. Only problem the import script depended on the files being named precisely according to a specific rule. But for [...]

June 3, 2009  Tags: , , ,   Posted in: Development  No Comments

Bash Oneliner for Counting Files

I needed to find a way to count the number of files in a directory and only output that number. Bash is still my best friend for this sort of thing – especially with a little help from google.

ls -1 | wc -l

by the way – the answer was 2062 files.

May 14, 2009  Tags: , ,   Posted in: Development  2 Comments

Renaming file extensions with bash script

A couple of weeks ago I had to rename the file extension of several view scripts from html (from my own mvc framework) to phtml (zend framework). I found, as always, bash to be my friend.

for i in *
do
( file $i | grep html ) && mv $i $(echo $i | sed [...]

April 30, 2009  Tags: , , , ,   Posted in: Development  One Comment

How I sorted All My Mp3’s With a Simple Bash Script

First of all, the headline is a lie. I am in the process of copying all mp3 files that we in our household have had on a number of different machines to one central server, which all computers talk to via webdav. But since we have had a lot of different naming schemes and ways [...]

March 12, 2009  Tags: ,   Posted in: Development  No Comments