Results 1 to 5 of 5
I keep getting a syntax error when I try to run this script, I have tried moving things around but I keep getting the same result, what am I doing ...
- 05-31-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 2
[SOLVED] running awk
I keep getting a syntax error when I try to run this script, I have tried moving things around but I keep getting the same result, what am I doing wrong?
#!/bin/awk -f
awk '{print "Name", $1, $2
print "Phone Number", $3
print " "}' phone.list
- 05-31-2008 #2
You only need to use the "print" statement once, at the beginning.
Code:#!/bin/awk -f awk '{print "Name", $1, $2, "Phone Number", $3," "}' phone.list
Men occasionally stumble over the truth,
but most of them pick themselves up
and hurry off as if nothing had happened.
Winston Churchill
... then the Unix-Gods created "man" ...
- 06-01-2008 #3Linux User
- Join Date
- Jun 2007
- Posts
- 318
I think alink wants to run awk in a script and have 3 lines of output for every line in the phone.list file. The script should look like as:
To do it with a single print command it would look like:Code:#!/bin/bash awk '{print "Name", $1, $2 print "Phone Number", $3 print " "}' phone.list
Code:#!/bin/bash awk '{print "Name", $1, $2, "\nPhone Number", $3, "\n"}' phone.list
- 06-01-2008 #4Just Joined!
- Join Date
- May 2008
- Posts
- 2
Thanks I will try it right now
- 06-01-2008 #5Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044



