How do you intend to use this? Are you planning on using it as a command-line script? In which case, you'll need to package it like this hello world question.
Or, are you planning on using it interactively, in which case you probably want the output in a new buffer...
This code gets the basics done. You'll need to update it to match your usage model.
(defun awk (filename &rest cols)
"Given a filename and at least once column, print out the column(s) values
in the order in which the columns are specified."
(let* ((buf (find-file-noselect filename)))
(with-current-buffer buf
(while (< (point) (point-max))
(let ((things (split-string (buffer-substring (line-beginning-position) (line-end-position))))
(c cols)
comma)
(while c
(if comma
(print ", "))
(print (nth (1- (car c)) things))
(setq comma t)
(setq c (cdr c)))
(print "\n")
(forward-line))))
(kill-buffer buf)))
Trey Jackson
2010-02-14 07:41:33