The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
A program to trace execution of another program jiten_hegde High Level Programming 3 08-19-2008 06:26 AM
C++ map program - Error message dhanamurthy High Level Programming 0 04-02-2008 07:57 PM
Program Error Carmen123 AIX 0 11-23-2006 07:20 AM
unix - c program sending error from DB to email chino_52284 Shell Programming and Scripting 2 04-28-2005 09:12 PM
Error Compiling C program Vivek High Level Programming 3 10-25-2001 12:13 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-07-2008
bikas_jena bikas_jena is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 13
Error in AWK Program

Hi Friends,
I need your help.

I am not able to execute one awk program .If you can solve the following small program
then i can solve other one.

$ vi prg

#!/bin/awk -f
BEGIN {

# Print the squares from 1 to 10 the first way

i=1;
while (i <= 10) {
printf( "The square of ", i, " is ", i*i);
i = i+1;
}

# now end
exit;
}

then i made chmod 777 prg

when i execute like
$prg
The square of The square of The square of The square of The square of The square of The square of The square of The square of The square of $

its coming like this.

Please let me know where i have done the mistake.

Thanks in advance
Bikas
  #2 (permalink)  
Old 01-07-2008
shamrock shamrock is online now Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Quote:
Originally Posted by bikas_jena View Post
printf( "The square of ", i, " is ", i*i)
Add the missing %i's for printing the num & its square...

Code:
printf( "The square of %i is %i\n", i, i*i)
  #3 (permalink)  
Old 01-07-2008
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 712
Hi.

Or remove the "f" from "printf" -> "print" ... cheers, drl
  #4 (permalink)  
Old 01-07-2008
bikas_jena bikas_jena is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 13
Thanks a lot frnds.
I change it to print from printf and its working.


Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0