Eddie On Everything

Don't get me started

Entries for the ‘perl’ Category

Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space

The copy command “cp -al” found on all versions of Unix/Linux creates what’s called a “hard link” to a file. The nice thing about this command is that it doesn’t create an actual copy of the file on disk – instead, it creates a “link” or pointer to the file data on the disk. [...]

Using rsync & ssh to Backup Files Between Linux Machines (Perl)

This script performs a network backup using unix’s rsync command over ssh. It performs an incremental backup, which means that it only updates new files and files that have changed since the last backup, thus minimizing network traffic.
This script runs on the source machine (SOURCE) and connects to the backup machine (BACKUP). [...]

How to do a search and replace in multiple files using Perl

Over the years, I’ve written a number of “search and replace in multiple files” scripts. Working on a computer that didn’t have my standard, custom toolset available, I found myself searching for an alternative.
Found this tip over at Dzone Snippets – do it all with a single line of perl.
perl -pi -w -e [...]

Automatically renaming files downloaded with Coast to Coast AM Media Center

I’m an insomniac.
I have trouble falling asleep at night because thoughts never seem to stop racing through my head – Did I do X yet? What if I did Y? Ooh, I could make it easier to do Y … Hey, I have a cool idea for an awesome invention… [...]

How to do a search and replace in multiple files using perl and linux

So you’ve got 100 files in a directory and you want to replace the string “foo” with “bar”. Stop before you waste your time opening up every single file and making the change, you can make all of the changes with a single line of perl.
perl -pi -w -e ’s/foo/bar/g’ *\.php
On his blog, [...]