There are many scripts using perl,php,python etc. that will do this for you
but the way you are about to see will make you smile of the simplicity of it .
instead of going over the file line by line and search inside , i am going to use
a tool that is going to do that for me . this tool is lynx , the console browser .
and here is how it works :
lynx -dump file_name.html
now, lets say our table looks like this :
to create a csv file from it , one would do something like this :
use ‘tr’ command to fold all spaces
tr -s " "
now , lets use sed to do the rest of the work for us .
this sed command will remove the first space/tab from the beginning of the lines
sed 's/^[ t]*//'
this sed command will place comma “,” as delimiter instead of space delimiter
sed 's/ /,/g'
So in the end we will end up with a simple one line command that creates a csv from html
lynx -dump file_name.html | tr -s " "|sed -e 's/^[ t]*//' -e 's/ /,/g' > file_name.csv
* note : the method shown here can work as long as there are no spaces in cell data
This common task turn out to be a pain in the … if you dont know how to do it .
Ubuntu unlike other Linux distributions moved from traditional sysvinit to Upstart .
i will not name all the differences but just one fact that setting a service to run in
requiered runlevel is not done by stop/start links in /etc/rcX.d anymore, but by init scripts .
Lets start . I use lxde as my desktop and lxdm as my desktop manager ,
i would like to have no Xserver on runlevel 3 ( runlevel 2 is Ubuntu default ) .
in order to do so i edit the file /etc/init/lxdm.conf and set the runlevels i wish lxdm
to start and stop . that is done by the commands
start on runlevel 
stop on runlevel 
start on runlevel , was not found on the script so i added it .
now lxdm will start only on runlevel 2 and would stop on runlevel 0,1,3,6
Now boot into grub entry and append the runlevl to the kernel parameters
linux /boot/vmlinuz-2.6.38-8-generic root=/dev/sda1 ro quiet 3
to make it permanently you can create a new menu entry on /boot/grub/grub.cfg
You can read more on upstart at http://upstart.ubuntu.com/index.html
Have you ever needed some command that you worked so hard for it
but it has being too long ago that it is already gone from Bash history ?
a simple solution is to use PROMPT_COMMAND Bash parameter .
how it works : PROMPT_COMMAND will execute the value as a command prior to issuing each primary prompt.
so if we set something like “history 1 >>~/.myhistory” , bash will write
the last history line to ~/.myhistory . nice ha
so in other words what can i do with that ?
well you can keep track of all commands , but there is a security issue
that needs to be taken , because this file saves all your history command ,
if you enter some passwords like running “mysql –password=blabla …”
it would be saved . so the first step would be to set permissions over the file
so only you can read it ( 0600 )
~$ chmod 600 ~/.myhistory
now lets put it all together by adding the line to your .bashrc
PROMPT_COMMAND='history 1 >> ~/.myhistory'
now when ever you login , the file will hold all your history ,
but now you see that every you press will write as the last command
as duplicate lines . the way i found to go around this is to simply remove duplicate
lines at login/logout . add this lines to ~/.bash_logout or ~/.bashrc
cat .myhistory |uniq >.myhistory2
mv -f .myhistory2 .myhistory
Have you ever wanted to have Tab to auto complete
any service and commands that comes with it ?
well i am going to show you how easy it is to do so .
all you need is to install a simple package that will do all the
hard work of typing for you .
the package name is bash-completion
once installed , you need to reload your profile and that’s it
just type service and tap will show you all services available
on your /etc/init.d . after you select the service you can hit tab once more
and it will display/complete the command associate with that service .
there is how ever another way of doing exactly that , by adding
words to bach tab completion . in this method all one needs to do is
run this command as root
~#complete -W "$(ls /etc/init.d/)" service
the advantage of the package bash-completion is that it gives you some more
options as completion . for example if you use the cd command ,
it would auto complete only the directories listed under the current location .
without bash-completion the cd command + tab may show you files as well and
the best trick is that bash-completion also auto complete any commands related
to any service listed under /etc/init.d
choose what ever is best for you