Please subscribe to RSS Feed! :)

I needed to open a number of files and depending on the content, delete them. Here is a quick bash script to cat the file and ask a question to delete the file afterwards.
#!/bin/bash
VIEWER="cat"
if [ -d $1 ]
then
DIR=$1
else
echo "Enter a directory to clean"
exit 1
fi
for file in `ls $DIR`
do
$VIEWER $DIR/$file
echo -n "Delete file (y/n)? "
read RESP
if [ $RESP == "y" ]
then
echo "Deleting $DIR/$file"
rm -f $DIR/$file
fi
doneYou can change the viewer to something else, if you don’t want to use cat, and instead of deleting the file, you might want to move it somewhere else instead.


I use Ubuntu like dancing bear; The magic in that is this: its not that the bear dances so beautifully, but that the bear dances at all.
So here's my Dancing Bear recipe for configuring Xampp to start up automatically for Ubuntu 9.10.
The first thing you need to know: There is something wrong with the directions the show for doing this in the Xampp FAQs. This isn't really anyone's fault. But the commands they offer for finding out crucial data aren't right. So don't freak out.
You really only need to know three basic things to set this up. Four if you count one of my excuses as a thing you need to know.
So lets get to it:
1. I'm not going to go over this. Even a dancing bear can type cd and ls to change directories and list them. That is, I think, the minimum required to call oneself a dancing bear.
2. The root user in Ubuntu works in Run Level 2.
How do I know this? Because if I change to Super User, by entering the terminal command "sudo su" I can type "runlevel" from the root-level command line. This tells me I'm running at "N 2." This is important, because it means that you have to put your symbolic links to the lammp launch script into /etc/rc2.d/
3.Go then. Make some symbolic links. But before you do, know this: You're making symbolic links to /opt/lampp/lampp in the /etc/rc2.d/ directory. You are going to give these symbolic links special names that will tell the system, when it's booting or shutting down, whether to call /opt/lampp/lampp in the context of starting xampp, or stopping xampp. If the symbolic links name starts with an S, that means, call it in the context of "start" when the symbolic link starts with a K, that means call the script int he context of "kill."
So what you need to do is create two symbolic links to /opt/lampp/lampp. I do this by changing to the /etc/rc2.d/ directory, and then using these commands:
What should happen then is that two little symbolic links will appear in the /etc/rc2.d/ directory. Those links are what tell the system to run the lampp start up script when the system is starting. You should also run "sudo update-rc.d lampp defaults" from the command line, but I don't know why or if it really matters. Remember, its not that the bear dances beautifully.
4. Finally, and here's something you'll just need to suck it up and get over: The way my system works, the machine does not enter Run Level 2 until you've logged into the system. That means, since my whole goal was to make the lampp server start without my intervention, I enabled the Ubuntu desktop system to automatically log me in. Problem solved. Unless you really don't care about security don't run your system that way, it's stupid. One day you will get burned.