Tuesday, May 6, 2008

To replace strings in multiple files, do the following:

$find -name '*.txt' -print0 | xargs -0 perl -pi -e 's/old/new/g'

Sunday, March 9, 2008

Fonts in Fedora 8

First of all, I had to install OpenOffice in my Fedora system, KWord just couldn't cut :( But today, I noticed when creating a document that none of my favourite fonts were available, such as Arial or Times New Roman. It turns out these are considered Windows fonts and aren't included. Since I collaborate with a lot of people who use Windows, it is essential to have these fonts available. Here is how you do it (courtesy of the Fedora FAQ at http://www.fedorafaq.org/#installfonts):

1. Open a Terminal.

2. Become root:
$> su -

3. Download the MS Core Fonts Smart Package File:
$> wget http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec

4. Make sure that the rpm-build and cabextract packages are installed:
$> yum install rpm-build cabextract

5. Build the Core Fonts package:
$> rpmbuild -ba msttcorefonts-2.0-1.spec

6. Install the Core Fonts package:
$> yum localinstall --nogpgcheck /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm

Saturday, March 8, 2008

Fedora 8 Rules

I installed Fedora 8 a few days ago with KDE, and I just have to say that it is AMAZING. Previously I had been using Ubuntu. I was and still am a huge fan of Ubuntu, as it was the first distribution that let me completely break free of the clutches of Windows. However, Ubuntu was just crawling while working on a Java project in eclipse this week on my laptop. I actually got so fed up that I did the unthinkable, booted into Windows XP to work!

After going to bed feeling filthy, I woke up and decided to try out the Fedora 8 CD that came with my Linux Pro magazine. The CD was defective of course, so I proceeded to download the KDE live cd off of the Fedora website.

Installation went OK, although not as smoothly as Ubuntu's. However upon booting up I was instantly impressed. Not only did it look great, the thing that really caught me was at the lightning-fast responsiveness of the interface. The same laptop that was chugging with Eclipse and Firefox going at the same time now handles the task with ease and is way more responsive as a whole.

Anyway, long story short, what I really wanted to do is list some of the things that make Fedora 8 / KDE awesome:

  1. Speed: the interface kills anything else I've seen in terms of speed & responsiveness by far, including Windows XP, and Ubuntu with both Gnome and KDE.
  2. Looks: it looks very slick. Also comes with compiz fusion, which just so happens to work without any extra configuration for me (although I turned it off since speed is king for me)
  3. Software installation: Fedora is based on Red-Hat RPM, which is more supported and widely available than debian DEBs, and makes software just as easy to install as a Windows software, which is most peoples' argument against Linux.
  4. Multimedia: although setting up Mp3 support is a pain in the ass because of patent garbage, I managed to get it set up by doing things that a non-expert would be able to do. Once that was done, the multimedia apps RULE. Amarok for example kills any media player that I've ever seen: it's fast, lightweight, looks great, etc.
  5. Configuration: modifying xorg.conf is a major hastle with ubuntu. Whenever i'd screw it up, I'd have to reboot my computer, go into safe mode, blah blah. With Fedora you just back out of X (ctrl-backspace), change your xorg.conf, then get back into X with startx. The way linux is supposed to be, not everything all mashed into X-windows like ubuntu was.
  6. Development: setting up development tools is very easy. Also, because it's based on RPM you can get more current releases of software than with DEBs.
  7. Document viewing/editing: I must say I am very impressed with the KDE office suite. Haven't used it extensively, but so far it seems much better than the bloated pig that openoffice is. Time will tell whether or not I will need to install openoffice for compatibility reasons... As for viewing, KPDF is a remarkable piece of software. Destroys evince, and even Adobe Acrobat if you ask me. Even has text to speech via kttsmgr.
  8. Probably a lot more, but I have to get back to work now.

Search for a string in a list of files with grep/bash

Today I was trying to find which file the main() function was in, in a source code directory for a project that I'm looking at. To do this, you would do the following: and that's it

$> grep -lir "main" *

and that's it. So just call grep with -lir and the search string you're looking for, and in the files you're interested in (all files in the current directory in my case). The grep params are:

-l: outputs on the file name where the string occured
-i: ignore the case
-r: recursively look into all directories

Damn I love grep...

First post

I set up this blog basically so that I can track my computer related research discoveries somewhere, so that when other people out there come across the same problems, they'll be able to do a search in google and come across my solutions, without having to go through the same pain and struggle to find it that I did. Countless times search engines have come to my rescue when trying to solve some difficult problem, so now it's my turn to give something back. Hope you enjoy, feel free to drop me a line if you have questions or comments about something. /jeremy