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 the 'Logiciel Libre' Category

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

04 July
Comments Off

Software And Business Method Patents Are A Bad Idea

In a world of business method patents this is possible:
A Great Business Method Patent Joke

Business method patents allow the state to give someone a monopoly on a how they might do business.

Those pushing for their acceptance and those considering their acceptance should be aware of the fact that in the US the landscape has changed somewhat since a Supreme Court Judgement in a case commonly known as the “Bilski case”.

Groklaw article on Bilski.

It has been said that the patents and copyrights are heading  in a direction that might be compared with buying a car from a garage and finding you might only be able to get that car fueled in a garage of that brand. Work out how restrictive that would be, do you find that acceptable?

14 June
Comments Off

What To Say When Someone Says No More GNU/Linux Distributions

When someone gives the:

We have too many free software programs talk and that is bad, we need fewer higher quality ones and unite.

I have the following stock answer now ready.

We have too many cars and that is bad, we need fewer higher quality ones and unite.

30 May
Comments Off

BSA in Czech Republic need to be pointed at

The Czech Republic Ministry of Finance And the BSA came up with this brilliant idea (ok that is a scarcastic comment):


No tax relief on hardware bought without software on it. I don’t know about you but I try to buy “white boxes” as they used to be called, that is hardware built to my spec with no software on it, why because I use GNU/Linux.

Why, not just as a hobby, where I work we save in excess of a hundred thousand euros because we can, by not paying Microsoft for their software and using as a viable alternative GNU/Linux.

Where I am it is not an IT or Web company, it is a service company with people doing administrative work and one IT person, me. We manage lots and do almost all of it with GNU/Linux, it really is that simple. Why do we have any Microsoft software at all? Because some external suppliers require it, because they are not neutral in the way they build web sites, yuk.

However they are few and far between. At least we have some competitive advantage in that we can claim these expenses. I hope the person who made that decision in the Czech republic ends up understanding what they are doing to their own economy, piping money out for no internal gain, great trick if you can do it.