2012w08

Hacks

A capture the flag game where the objective is to break into a computer system.

Commandline

I found myself needing to remove a couple (three) columns from a file containing about 15 columnts per line. And sure, I could have done something like awk '{ print $1 " " $2 " " $3 " " }' for the 12 columns I wanted, but that would have been tedious.

There just had to be a better way. And of course there was ;)

* * * * * *

I’ve been entertaining an idea which would need version controlled updates, and they’d also need to be trusted. So I’d need signed commits, and since I’m mostly using git nowadays, I needed to find out if this was possible. It is.

* * * * * *

Since starting my new job I’ve realized just how important it can be to write portable scripts (especially echo has bitten me in the ass a couple of times already) so this post was pretty useful to me.

Society

Now this was a pretty inspiring post.

* * * * * *

A pretty funny post about how truly sorry a state the TV is in.

Tags: , , , ,

4 Responses to “2012w08”

  1. Flo says:

    Hello,

    >So I’d need signed commits
    I’m not sure, but isn’t that the way how the kernel.org-stuff is doing their things with git?

    Flo

  2. Brandon says:

    re: getting specific columns from a delimited file, just use the cut command…no need to use awk for something so simple.

    Using the example from the link you gave, where the file contains:
    AX|23.45|1932323|A|VI|-|Y|0
    TY|93.45|2932323|B|VI|-|Y|1
    RE|63.25|8932323|A|VI|0|N|1
    AY|83.85|0932323|C|VI|-|Y|0

    And he doesn’t want columns 2 and 7. Just do:

    $ cut -f 1,3-6,8 -d\| FILE

    (here you have to specify the delimiter, since cut assumes it’s TAB). You can specify as many fields (including ranges like 3-6) as you want with the -f argument.

  3. Patrik says:

    It may very well be, I hadn’t really researched it, or even thought about if it was even possible at all, so I was pleasantly surprised :)

    /Patrik

  4. Patrik says:

    Hello :)

    There are three reasons for me using awk instead of cut:

    1. Poor memory/thinking: I never thought about cut ;)
    2. Familiarity: awk is pretty well-used at work
    3. Laziness: It is easier for, at least in my mind, to exclude specific fields, than to construct a range of included fields ;)

    But you are right, I should use cut more :)

    Cheers,
    Patrik