Using sed to change strings in multiple files

September 15, 2007 – 21:56

Ok, one more tip for today, which makes it very simple to change text within multiple files.
Say for example that you want to change Bush to Kerry in 50+ files ending with “html”.
OK, now you could edit them, but it is too much of a hustle. Instead let’s use sed and some bash scripting:

for F in `find ./ -type f -name '*.html' -print`;
do mv $F $F.tmp;
sed 's/Bush/Kerry/g' $F.tmp > $F;
rm $F.tmp;
done;

Be careful however, when changing “<” or “>” or any other character that has to be escaped! You have to escape it using a backslash – “\”. So for example to escape a “<” you would write “\<”. SIMPLE, right?

Questions? Here is a sed string changing script that I used.

Unzip, untar, unpack all archives

September 15, 2007 – 21:13

Once I came to a point of having downloaded 20+ tar.gz files and facing a need of finding an efficient way to extract them. If you are having such a problem then this simple solution will help:

for F in `find ./ -type f -name '*tar.gz' -print`;
do tar xvzf $F;
done;

What it does is for every file ending with “tar.gz” found in current folder “./” it executes a command “tar xvzf“, which unpacks the archive. Very simple but also VERY useful. Try with unzip and other commands.
Yes, you may delete files after unpacking by adding “rm $F;” after the tar statement.
However, it is always good to keep the original source!

How to use the gallery

September 15, 2007 – 21:04

New gallery is very powerful and features some dynamic content. I am sure you will be able to use it in the most efficient way. Here are some tips:

Click on Show sidebar in order to show the sidebar. After the sidebar is shown you can click on “Show Item Links” in order to have access to direct slideshows. A new icon will be shown next to the photo Action. Click on it and choose option of your interest.

When you are done with choosing options for your slideshow it is better to hide the sidebar by clicking Hide sidebar.

Polska wersja tutaj: Read the rest of this entry »

Website updated

September 15, 2007 – 19:54

Hello to everyone!

I finally managed to update my website a bit so it satisfies my needs better. I have configured a WordPress blogging application with custom plugins.

Website features a brand new gallery, commenting possibilities and much more.

ENJOY and if you wish then participate actively in the development of this website!

You may want to register by clicking this link.