News for hackers. Stuff that matters.
Re:Why you should learn just a little Awk - A Tutorial by Ex... by RexRollman on Saturday August 27, 2011 @05:49PM (#2932620)
Would Awk be useful for end user plain text databases? I want to keep a listing of all my books but I would prefer not to use a database and to use something that works in the Unix console.
Re:Why you should learn just a little Awk - A Tutorial by Ex... by telemachos on Saturday August 27, 2011 @05:55PM (#2932637)
The Awk Programming Language[1], by Aho, Kernighan and Weinberger, has a whole chapter on using Awk as a relational database engine. (They implement a small query language in Awk itself.) It's also a great book period.

[1] http://cm.bell-labs.com/cm/cs/awkbook

Re:Why you should learn just a little Awk - A Tutorial by Ex... by ed2417 on Saturday August 27, 2011 @09:41PM (#2933047)
I agree , great book. Have you checked the price lately?
Re:Why you should learn just a little Awk - A Tutorial by Ex... by telemachos on Saturday August 27, 2011 @10:18PM (#2933098)
Luckily, I don't need to: I picked it up from Amazon (university library sell-off) after silentbicycle recommended it here some time back.

(You made me curious: there are used copies at Amazon starting at around $6.00[1].)

[1] http://www.amazon.com/gp/offer-listing/020107981X/ref=dp_olp...

Re:Why you should learn just a little Awk - A Tutorial by Ex... by pkrumins on Sunday August 28, 2011 @03:37AM (#2933529)
I wrote an e-book on Awk two months ago:

http://www.catonmat.net/blog/awk-book/

It teaches Awk through many practical examples, so called one-liners, that are small and short programs that just do one task. Such as joining lines, printing lines matching a pattern, summing up numbers on lines, converting text, etc.

Re:Why you should learn just a little Awk - A Tutorial by Ex... by hesitz on Saturday August 27, 2011 @07:19PM (#2932818)
Something like the 'NoSQL' project might be just what you're looking for: http://www.strozzi.it/cgi-bin/CSA/tw7/I/en_US/nosql/Home%20P...

This 'NoSQL' has absolutely no similarity to the 'NoSQL' databases of the last few years (and predates them all by many years). Instead it's a tool to manage databases of plain text files in the Unix environment. Seamlessly ties together several parts of Unix toolchain, with Awk as the centerpiece. Has surprising features, like searches with joins between tables (i.e., files).

I'll also second that the Aho Kernighan Awk book is a beautiful piece of work.

Re:Why you should learn just a little Awk - A Tutorial by Ex... by crazydiamond on Sunday August 28, 2011 @12:58AM (#2933333)
That link (nosql) looks interesting. Also do look at crush-tools. You can even pivot data with it.

http://code.google.com/p/crush-tools/wiki/CrushTutorial

Re:Why you should learn just a little Awk - A Tutorial by Ex... by LiveTheDream on Saturday August 27, 2011 @06:36PM (#2932742)
Depends on how complex the expected operations are. I think awk is absolutely essential for dealing with things like logfiles. Do you have a reason against using sqlite[1]? That works just fine in the console, doesn't need a server. You could still use awk with it, technically. For example:

    bash..$ sqlite3 books.sqlite
    sqlite$ create table books ( title varchar(128), author varchar(128) );
    sqlite$ insert into books (title, author) values ("Snow Crash", "Neal Stephenson");
    sqlite$ .quit
    bash..$ echo "select * from books;" | sqlite3 books.sqlite
    Snow Crash|Neal Stephenson
[1] http://sqlite.org/
Re:Why you should learn just a little Awk - A Tutorial by Ex... by adamjernst on Saturday August 27, 2011 @06:47PM (#2932762)
You don't even need to pipe the command in; just put it as the second argument after the database file.

    $ sqlite3 books.sqlite "select * from books"
Re:Why you should learn just a little Awk - A Tutorial by Ex... by LiveTheDream on Saturday August 27, 2011 @07:33PM (#2932846)
Thanks for the tip
Re:Why you should learn just a little Awk - A Tutorial by Ex... by viraptor on Saturday August 27, 2011 @06:03PM (#2932661)
Why would you want to do that? It looks like xml all over again. No advantages of user-readable format and no advantages of a real database. Talking to sqlite CLI tool is probably a little bit more useful.
Re:Why you should learn just a little Awk - A Tutorial by Ex... by 4ad on Saturday August 27, 2011 @06:08PM (#2932678)
XML? I keep databases in user readable/writable format that I also parse with awk. The whole point of awk is to parse human readable text. No XML nonsense. Just text with a non-rigid structure.
Re:Why you should learn just a little Awk - A Tutorial by Ex... by viraptor on Saturday August 27, 2011 @08:22PM (#2932927)
That was my question - why do that?

If you need a database, you really shouldn't allow the text to be parsed as anything else than originally intended. With "just text with a non-rigid structure" it's just too easy to make a silly mistake. So what is the advantage here, given we have bdb and sqlite on almost every machine nowadays?

Or the other way - if you need something human-readable, why use is as a database? Why not keep the data where the data belongs and generate the reports when needed from there?

Re:Why you should learn just a little Awk - A Tutorial by Ex... by a3_nm on Sunday August 28, 2011 @05:31PM (#2935044)
You might be interested by recutils: https://www.gnu.org/s/recutils/