awk tutorial confusion



Readers,

I am reading a tutorial, to learn how to use awk (http://
www.grymoire.com/Unix/Awk.html).

I've copied the following text and saved in the filenames shown:

fileowner:

#!/bin/sh
awk'
BEGIN {print"file\towner"}
{print $8,"\t",$3}
END {print "-done-"}
'

fileowner2:

#!/bin/sh
awk '
BEGIN { print "File\tOwner" }
{ print $8, "\t",
$3}
END { print "done"}
'

fileowner3:

#!/bin/sh
column=$1
awk '{print $column}'


Below is my various command terminal errors:

$ awk -f fileowner.awk
awk: fileowner.awk:2: awk'
awk: fileowner.awk:2: ^ invalid char ''' in expression
$ awk -f fileowner2
awk: fileowner2:2: awk '
awk: fileowner2:2: ^ invalid char ''' in expression
$ ls -l|Column 3
bash: Column: command not found
$ ls -l|fileowner3
bash: fileowner3: command not found

Regarding the fileowner file, I obtained the same error both when the
filename has no suffix and when the suffix is .awk. Subsequently I did
not use .awk farther. What am I doing wrong?

Yours,

gnu mandriva 2008
gnome 24
.



Relevant Pages

  • Re: Command piping question
    ... In awk, the default field separator is a space. ... Why use xargs? ... Because rm itself doesn't take filenames to nuke from ... maximum length of arguments for a single command. ...
    (comp.unix.aix)
  • Re: Removing lines from a plain text file
    ... Apparently there is no simple command. ... > and put prune in a cron job. ... > size by removing the excess from the beginning of the file. ... date from the past and use awk to search through the file for it and discard ...
    (comp.unix.sco.misc)
  • Re: Closing a field
    ... I thought of the same solution, that of using the field number count as the discriminant, mainly because I don't have any idea how to use AWK to validate a field as a number. ... The treatment of tabs as an alias for spaces in some POSIX is motivating me to stay away from them. ... already have a filter called 'join' so why not use AWK to create a filter called 'select' and for other SQL commands as well. ... I'd want to call the script by its SQL command name and use it as an SQL-like Unix pipe filter. ...
    (comp.lang.awk)
  • Re: Interesting math
    ... One thing I've learned is that it's often a superior language for ... And if you want to do build up a command line, ... Write the script in Perl instead, and all these problems just go away. ... anything you could do from a C program, or an awk program for that matter. ...
    (alt.usage.english)
  • Re: Problem while executing "system " in awk
    ... There is a file(named myno) containg phone numbers. ... I've written following awk prog ... Please suggest why my systemcommand is not executing ... it is possible that the shell is seeing your command as ...
    (comp.lang.awk)