awk BEGIN problem

awk 
'BEGIN { 
    print "line one\nline two\nline three" 
}'

After ./awktest.sh

Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options:        GNU long options:
    -f progfile        --file=progfile
    -F fs            --field-separator=fs
    -v var=val        --assign=var=val
    -m[fr] val
    -W compat        --compat
    -W copyleft        --copyleft
    -W copyright        --copyright
    -W dump-variables[=file]    --dump-variables[=file]
    -W exec=file        --exec=file
    -W gen-po        --gen-po
    -W help            --help
    -W lint[=fatal]        --lint[=fatal]
    -W lint-old        --lint-old
    -W non-decimal-data    --non-decimal-data
    -W profile[=file]    --profile[=file]
    -W posix        --posix
    -W re-interval        --re-interval
    -W source=program-text    --source=program-text
    -W traditional        --traditional
    -W usage        --usage
    -W use-lc-numeric    --use-lc-numeric
    -W version        --version

To report bugs, see node `Bugs' in `gawk.info', which is
section `Reporting Problems and Bugs' in the printed version.

gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output.

Examples:
    gawk '{ sum += $1 }; END { print sum }' file
    gawk -F: '{ print $1 }' /etc/passwd
./awktest.sh: line 4: BEGIN { 
    print "line one\nline two\nline three" 
}: command not found

Hi.

Not this...

awk 
'BEGIN { 
    print "line one\nline two\nline three" 
}'

But this...

awk '
  BEGIN { 
    print "line one\nline two\nline three" 
}'

or this...

awk \
'BEGIN { 
    print "line one\nline two\nline three" 
}'

Thank you.
But this is not working:

awk \ 
'BEGIN { 
	print "line one\nline two\nline three" 
}'
./awktest.sh: line 4: BEGIN { 
	print "line one\nline two\nline three" 
}: command not found

Post the content of your script between code tags.

Regards

Posting the code again.

awk \ 
'BEGIN { 
	print "line one\nline two\nline three" 
}'

Hi.

It should work.. it works for me!

Use the other one instead then

Your script should looks like:

#!/bin/sh

awk 'BEGIN { 
    print "line one\nline two\nline three" 
}'

This should work too:

#!/bin/sh

awk \
'BEGIN { 
	print "line one\nline two\nline three" 
}'

Regards

I got the problem.It's the extra space after the "\" character.
If I copy and paste this it works.

awk \
'BEGIN { 
    print "line one\nline two\nline three" 
}'

But if I copy and paste this it doesn't work.(copy and paste the below one you will get error).Extra space after "\" character.

awk \ 
'BEGIN { 
    print "line one\nline two\nline three" 
}'