Words Myte Bite

Funny can be whatever you want it to be. The Words and Musings of Paul O'Malley. Sort of a Blog!

Archive for April, 2011

06 April
Comments Off

Just some random dates

The new Dáil will sit on March 9th when votes will be taken on a new Taoiseach.

That sentence was applicable in two separate years, 1932, and 2011.


06 April
Comments Off

More Fun bits of Bash / Sed and Awk Shell Fun

So you want to split a file in two (even or uneven).

The command `split` will do this for you.

Should you wish to use it, it defaults to 1000 lines for large files as the point to split a file.

However, if you want to split a file which has 701 lines and you want to split it at the 502 line, then you would simply do this:

split -l502 SplitMeFileName

and the file would be split in two pieces.

They would be called xaa and xab unless you state what the file should be called.

Nine Digits turned into something with two decimal places, and with commas for thousands.

sed ‘s/./\.&/8′ FileWithNumbersToBeParsed | sed ‘s/./\,&/5′ | sed ‘s/./\,&/2′ >foo

or how to turn




The .& or ,& puts the comma or decimal point in the correct location, start on the right hand side or you will have more fun than you need.

(try it to find out :-) )

This is how you insert a character into a string.


You want to put a leading space into every line in a file?

sed ‘s/./\ &/’ FileName

What might not be obvious from this line is the space before the &.

And some Awk ;-)  

date | awk '{print $2 " " $6}'
how to print specific strings from some random input.
date Wed Apr  6 23:15:10 IST 2011
we get the output
Apr 2011

That's all folks.




05 April
Comments Off

Fun bits of Bash / Awk Shell Fun

Without going into the why’s I thought I would publish these few lines to amuse some of the people I know get the odd ping from this blog.

There are a long list of numbers in Subt, I want to get a running total (that is the awk bit).

Not only that but then I padded all the lines using printf  so that if they were not nine digits long they were padded in front of them.

cat Subt | awk ‘{s+=$1} {print s}’ | xargs  printf “%09d\n” > RunningT

Had I wanted a total then this would have worked:

cat Subt | awk ‘{s+=$1} END {print s}’ > FileContainingTotal

How to select a variable from a long list using a simple gui command.

(the file RunningT is several hundred lines long)

kdialog –menu “select your amount” $(cat RunningT) –geometry 700×400

(no I don’t know how to do that with zenity, or even if it can be done {yay for kludge})

Now if that is not enough fun, get a giggle at this one:

cat RunningT | awk ‘{ print FNR “\t” $0 }’ > foo

Yes folks we can add an  line number to the file RunningT and create a new file called foo for no good reason.

The ways you can do this are many.

Cut lines off top of file three of them and park them somewhere.
head -n3 SourceForComputation > HeaderPrep

tail does the other end of the file

One of the problems I had with this little adventure was to insure that specific content was always placed in the the file but it could be scattered around the place (I would be splitting the file later)

You can use sort, however that might put your data in a strange place.

So grep for that special_data to extract it  and redirect it to a holding file.

Fine how do you remove specific data from a file so you don’t duplicate your processing of it?

grep -Ev What\ I\ Want\ Removed  File-to-remove-data-from > Result


(woops I had first published this as Ve)

and we get a Result

Anyway that was just a few notes on the fun parts of processing data using bash and awk

05 April
Comments Off


Went back to improv classes for the first time in a long time last night. Great craic.

It is a little like riding a bike, you remember when you get back to it how it went.

Enjoyed it!


05 April
Comments Off

The Strange Adventures Of A Pixel

(Just because someone wanted to know!)


What is a pixel?

It is a single spot which can represent any colour within the bounds of physics for the device.

How can we understand pixels?

Firstly let us think of some units of measurement:

kilo K 1 000

mega M 1 000 000

However in Computers:

1024 is a kilobyte (kB), 1024 x 1024 is a megabyte (MB)

(mibibytes MiB in binary 220 same size as a MB, not an SI measurement)

In Cameras to find the Dots per inch we use this formula:

Resolution = Print Size

Dots Per Inch

With colour about 250 dots per inch is about the minimum amount of dots that are needed for the human eye to see before an image begins to look a bit broken up and made of squares.

(It might be useful to think of being close to a Monet picture.)

A Nikon chart for some cameras has some Megapixel cameras with these pixel sizes:

Megapixel Resolution of Camera
10.75 3872 x 2592
12.9 4228 x 2848
16.9 4928 x 3264

So what can you reasonably expect with a portrait shot on the 10.75 Megapixel camera.

Can we do a 16 x 24 inch? To find out we must calculate the DPI.

(DPI) We calculate the Values of X and Y as below.

3872 / X= 16              (Answer X= 242)

2048 /Y = 24              (Answer Y= 85)

So 242+85 = 327 DPI This would call a good quality picture to look at, as for it’s content that is a whole other story.

(Note this is printing portrait from a landscape shot, we would get a better score had we taken the shot as a portrait !)

However the same camera printing to 32 x 48 inches would give 168.5 DPI you will see squares!


Want your own copy of this a PDF: