The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
creating a file using Perl chriss_58 Shell Programming and Scripting 1 06-03-2008 07:41 AM
Creating a file ravisg Shell Programming and Scripting 2 05-10-2008 06:15 AM
help with creating new log file john89011 Shell Programming and Scripting 0 02-29-2008 12:45 PM
Creating a txt file outthere_3 UNIX for Dummies Questions & Answers 1 01-31-2008 11:09 PM
Creating a csv file based on Existing file skywayterrace Shell Programming and Scripting 3 12-02-2007 09:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-29-2008
Segwar Segwar is offline
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
  #2 (permalink)  
Old 02-29-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Replace the awk command with:

Code:
awk '{printf("%d/t"|"%d/t"|"%d/t\n", $1, $2, $3)}' >> tempfile.txt
Regards
  #3 (permalink)  
Old 02-29-2008
Segwar Segwar is offline
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
  #4 (permalink)  
Old 02-29-2008
Segwar Segwar is offline
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
  #5 (permalink)  
Old 02-29-2008
Segwar Segwar is offline
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?
  #6 (permalink)  
Old 02-29-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
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
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 03:48 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