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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
creating a file using Perl chriss_58 Shell Programming and Scripting 1 06-03-2008 04:41 AM
Creating a file ravisg Shell Programming and Scripting 2 05-10-2008 03:15 AM
help with creating new log file john89011 Shell Programming and Scripting 0 02-29-2008 08:45 AM
Creating a txt file outthere_3 UNIX for Dummies Questions & Answers 1 01-31-2008 07:09 PM
Creating a csv file based on Existing file skywayterrace Shell Programming and Scripting 3 12-02-2007 05:19 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-29-2008
Registered User
 

Join Date: Feb 2008
Posts: 13
creating a csv file in awk

Hi All
I am trying to create a csv file in the korn shell and the script segment is as follows:
Code:
if [ percent -gt 80 ]
        then
# NEED TO ADD INFO TO THE EMAIL FILE ABOUT THE DRIVE THAT'S FILLING UP
        echo "$drive  $percent%  $space "|\
 awk '{printf("%d/t"|"%d/t"|"%d/t\n", $drive,$percent%,$space)}' >> tempfile.txt
now i am getting a syntax error when the script is run.
Code:
awk: syntax error near line 1
awk: illegal statement near line 1
it seems that i am making an elementry mistake that I am not able to catch
the $drive $percent and $space are integers and are being pulled from a df -k command
Please Assist
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-29-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,615
Replace the awk command with:

Code:
awk '{printf("%d/t"|"%d/t"|"%d/t\n", $1, $2, $3)}' >> tempfile.txt
Regards
Reply With Quote
  #3 (permalink)  
Old 02-29-2008
Registered User
 

Join Date: Feb 2008
Posts: 13
Quote:
Originally Posted by Franklin52 View Post
Replace the awk command with:

Code:
awk '{printf("%d/t"|"%d/t"|"%d/t\n", $1, $2, $3)}' >> tempfile.txt
Regards
Thanks Franklin,
I will try and get back
Reply With Quote
  #4 (permalink)  
Old 02-29-2008
Registered User
 

Join Date: Feb 2008
Posts: 13
Quote:
Originally Posted by Segwar View Post
Thanks Franklin,
I will try and get back
I tried and got the same error message
Code:
awk: syntax error near line 1
awk: illegal statement near line 1
Reply With Quote
  #5 (permalink)  
Old 02-29-2008
Registered User
 

Join Date: Feb 2008
Posts: 13
Quote:
Originally Posted by Segwar View Post
I tried and got the same error message
Code:
awk: syntax error near line 1
awk: illegal statement near line 1
shoud I try to replace the $1 $2 and $3 with the drive percent and space variables?
Reply With Quote
  #6 (permalink)  
Old 02-29-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,615
Sorry, I just copy and paste the first piece of the printf statement, try this:

Code:
awk '{printf("%d/t|%d/t|%d/t\n", $1, $2, $3)}' >> tempfile.txt
Regards
Reply With Quote
  #7 (permalink)  
Old 02-29-2008
Registered User
 

Join Date: Feb 2008
Posts: 13
creating a CSV in awk

Thanks ...
appreciate your prompt response
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0