Sed – Stream Editor – Cheat Sheet – good coders code, great reuse I present to you my cheat sheet of sed, the Superman of stream editing! It has come handy 101 times for me because sed is not what I use daily and after some time of not using the sed commands tend to [...]
Also filed in
|
|
For a little test script I’m writing I needed to split a line on a ‘;’ but preservere the “s and ‘s, something that echo doesn’t like to do. Digging deeper into the bash docs I see that there are some handy string handling functions. #!/bin/bash line=’this “is” a command;this “is” a pattern’ COMMAND=${line%;*} PATTERN=${line#*;} [...]
Also filed in
|
|
I’ve been asked this a number of times and always have to look it up, so here are 3 ways to convert a unix timestamp (seconds since Jan 1, 1970 GMT) to a real looking date. Perl method 1: use the ctime module: perl -e “require ‘ctime.pl’; print &ctime($EPOCH);” Perl method 2: use the scalar [...]
Also filed in
|
|
Open Tech Support – [Unix/Linux] Linux Shell One-Liners A handy little list of some one liners. I use stuff like this every day and should really get in the habit of posting them. A short introduction to getting a little more from your shell with piping & redirection
Also filed in
|
|
.!. Last time I tweaked the parser, tonight I’m going to move some of the code into functions. Many people think of functions as a way to reuse the same code, but they can also be used to seperate logic into bite sized chucks. This can often lead to code that’s easier to read, and [...]
Also filed in
|
|
.!. In my last post I was using if and else to look for each tag, and act on it. Tonight I’m going to convert that ugly mess to a case statement. It’s easier to read, and doesn’t have the hackish feel of if then, else. I also learned a new trick that will help [...]
Also filed in
|
|