BASH for loop works nicely under UNIX / Linux / Windows and OS X while working on set of files. However, if you try to process a for loop on file name with spaces in them you are going to have some problem. For loop uses $IFS variable to determine what the field separators are. By default $IFS is set to the space character. There are multiple solutions to this problem.
fold is really nifty command line utility to make a text file word wrap. This is useful for large number of text files processing. There is no need to write a perl / python code or use a word processor.
I’ve directory called /home/vivek/scripts/daily with over 25 perl / shell / python scripts for managing daily tasks. One day for some weird reason my crond died and I did not noticed the incident for 2 days.
Now crond is started and I’d like to run all those scripts. Here is a quick for loop running all scripts in a directory called ~/scripts/daily/:
for s in ~/scripts/daily/*;do [ -x $s ] && $s || : ;done
Above script will run each and every executable script it finds in a directory.
Update: As pointed out by jeff (see below), you can use run-parts shell script for the same purpose:
$ run-parts ~/scripts/daily/*
Installing software from a source code is common practice in Linux and Unix world. Some time this is preferred method because it gives all power and flexibility you need to optimize your software such as MySQL, PHP, Apache and more. However, uninstalling files installed from a source code tar ball can be a big headache.
Two methods can be used to uninstall files:
Continue reading “Uninstall files installed from a source code tar ball on Linux or Unix”