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
doubt in awk jisha Shell Programming and Scripting 4 04-16-2008 04:02 AM
doubt about awk soujanya_srk UNIX for Dummies Questions & Answers 2 01-10-2008 05:26 PM
SDL doubt royalibrahim High Level Programming 0 11-22-2007 01:49 AM
awk doubt.. esham Shell Programming and Scripting 11 10-11-2007 02:24 AM
ftp doubt ranj@chn Shell Programming and Scripting 0 01-04-2006 08:47 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-06-2008
Rafael.Buria Rafael.Buria is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 16
AWK doubt

Hello people

I have a doubt about awk... I´m using it to create a condition where I do not want to use the 0 (zero) value of a certain column.

- This is the original file:

string,number,date
abc,0,20050101
def,1,20060101
ghi,2,20040101
jkl,12,20090101
mno,123,20020101
pqr,1234,20020101
stu,0,20000101

- This is the awk line that I´m using:

awk -F, 'BEGIN {OSF=","} { if ($2 != 0) print $1, $2, $3}' TEST.csv >> RESULT.csv

However the result is:

date number string
def 1 20060101
ghi 2 20040101
jkl 12 20090101
mno 123 20020101
pqr 1234 20020101

Can anyone tell me why it losts the ",". What am I doing wrong and how can I fix it?

Regards

Rafael Buria
  #2 (permalink)  
Old 02-06-2008
ag79 ag79 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 33
there's a typo
OSF needs to be OFS (Output Field Seperator)
plus u can write print $0 instead
awk -F, 'BEGIN {OFS=","} { if ($2 != 0) print $0}' TEST.csv >> RESULT.csv
  #3 (permalink)  
Old 02-06-2008
Rafael.Buria Rafael.Buria is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 16
Many thanks to you...
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 10:26 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