Articles Home

Quickie: Batch Renaming Files in Linux

Quick and easy way to rename files

For those wanting to be able to quickly and efficiently rename a bunch of files all at once, below is some example code to help you achieve that:ls *.xml | sed 's/\(testing\)\(.*\)/mv \1\2 production\2/' | shThe first piece ls *.xml simply lists the file types we want to change. You can, of cours...

quickie, linux, bash

Quickie: Data Mining on the Web with Perl

An extremely basic example of grabbing some data

This is a simple web mining script using perl.#!/usr/bin/perluse LWP::Simple;$numPages=$ARGV[0];open OUTPUT,">/home/user/out.html";for($i=1;$i<=$numPages;$i++){print $i."\n";        $content=get("".$i);        print OUTPUT $content;        print OUTPUT "*****...

perl, quickie, scripting, linux

Quickie: Deleting Old Files

Removing old files from Linux the fun way

Many people have the need to delete files older than a certain range. For instance, you may want to remove all podcasts that are older than a certain time period or delete other files that you receive regularly. Making use of the find command and mtime, you are able to delete them with ease.find ...

quickie, linux

Quickie: Multiple File Search and Replace

Solution: perl -pi -w -e 's/searchregex/replaceregex/g;' *.fileextension

If you've ever run into the necessity to change the same data over multiple files you know how hard it is to go through each and every file and update it by hand or at best do an indiviual regex on each. Here's how you can make the changes all in on fell swoop.perl -pi -w -e 's/searchregex/replac...

perl, quickie, scripting

Quickie: Strip ^M (Control-M) Characters from Input File with Perl

Command line removal of control characters

For anyone that does file I/O and has to sometimes work with Windows-generated files in Linux, I feel your pain. Windows has these little nuances that sometimes makes our GNU/Linux world a fun place to live. Luckily, PERL has a simple little system in place that allows us to remove control charac...

perl, quickie, scripting