|Free Software at Schools: Installing and Maintaining a Skolelinux/Debian-edu Network; Based on Debian Sarge, prerelease pr05|
Most system files are full of comment lines, that is lines with a #-symbol in front. These are lines that the program disregards. Sometimes we aren't interested in viewing these comment lines. We only want to see the lines that work. The command egrep -v '^#|^$' <filename> will filter out these comment lines when viewing the file- they won't actually be removed from the file itself.
Sometimes you have the need to make the same change to several different files, for example the configuration files for your users. Either you open them one by one and use the entire day on the job, or you can use a nice combination of Perl and shell scripting.
The following little bit will replace every reference to kde2 with kde3 in all files that have the file type .txt
for F in *.txt; do perl -pi.bak -e 's/kde2/kde3/g' $F;doneWhat's fine about this command is that the original file is left untouched (neither written over or deleted), rather it is given an extra ending, that is, .txt.bak. This is nice especially when you find out that your change wasn't the right thing to do after all- but you did do a backup anyway, right? See Section 8.5.3