Tag Archives: linux

Regex file rename.

Short post today, trying to post more often.

Ever had a folder full of files?  Universally, the answer to that is yes.  But, have you ever wanted to mass rename the files according to a pattern?  I had such a need today.  I had a poorly thought out backup script for my sql files.  I had named them all by date in the pattern mm.dd.yy.tar.gz.  That works just fine for a year but after that, they don’t sort well.  You end up with something like below.


See the problem?  Its not sorted properly when you get a folder listing.  Makes it difficult to determine which backups you actually have.  So, I wrote a little regex to rename them all.  I matched the first four digits ($1) the last set of digits ($2) and the rest of the file ($3).  Then I rename it in the form 20$2.$1.$3.  This has the effect of placing the year at the beginning of the file like i should’ve done to begin with.

rename -v 's/(\d\d\.\d\d)\.(\d\d)\.(.+)$/20$2\.$1\.$3/' *.gz

That one little command instantly renamed 731 files saving me an enormous amount of time and effort.  Knowing regular expressions has been a very useful skill.  I strongly encourage anyone interested to visit regular-expressions.info.


SSH Password Logging

So, i’m alive.  I know I don’t post as often as I should.  And I know you probably feel left out, alone, bereft.  Fear not, I am back.

Logging Attempted Passwords With SSH

Anyway, remember that post I made of ssh attempts way back when?  Well, I got bored.  I decided it wasn’t enough to see the usernames attempted, I needed to see the passwords attempted as well.  My first thought was to use one of the honeypot ssh servers that exist and simply run the real ssh on another port.  I didn’t like that approach.  For one thing,  I don’t want the attacker to actually make it in, not even to a fake environment.

Read more »

Software raid with linux.

Recently, i noticed my once massive 500 GB hard drive had been reduced to nothing more than 3-4 gigs of free space. I decided i wanted more. I also decided, i didn’t like the idea of one hard drive dying and taking every byte of data i’ve collected with it. This meant redundancy. Now, there are a lot of solutions out there for making storage redundant. But, I decided I had a price range of only $200-$300 total. There was now only one solution. Linux software raid. Read more »

A kitten prank.

Earlier today, i was sitting down, watching tv with my brother. We were both on laptops doing other things at the same time. He started watching an episode of loaded featuring 50 cent. I do not like 50 cent. After several minutes of the god-awful, talentless, garbage, i got sick of it. Did I go the pansy route and ask him to change it? No! I took the high road and made a few changed to my dns server causing all sites he tried to go to, to instead, go to kittenwar.com. I’ll show you how i did it.

Read more »

Page 1 of 212