Bits of Learning

Learning sometimes happens in big jumps, but mostly in little tiny steps. I share my baby steps of learning here, mostly on topics around programming, programming languages, software engineering, and computing in general. But occasionally, even on other disciplines of engineering or even science. I mostly learn through examples and doing. And this place is a logbook of my experiences in learning something. You may find several things interesting here: little cute snippets of (hopefully useful) code, a bit of backing theory, and a lot of gyan on how learning can be so much fun.

Friday, June 22, 2012

To Make Your Code Snippet Blogger Ready


#!/bin/bash

function toHTML(){
    local inFile=$1;
    local outFile="${inFile}.dat";

    if [ -f ${outFile} ]; then
        rm ${outFile};
    fi

    sed 's/\t/\ \ \ \ /g' ${inFile} > ${outFile}
    sed 's/$/ /g' ${outFile} > tempFile.dat;

    mv tempFile.dat ${outFile};
}


fileName="";
if [ $# == 0 ]; then
    fileName="\.";
else
    fileName=$1;
fi

toHTML ${fileName};

No comments: