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
Wierd thing about FSs and VGs mhenryj AIX 4 11-13-2007 04:42 PM
Wierd networking issue pflink UNIX for Dummies Questions & Answers 2 10-29-2007 06:19 AM
Wierd boot-up sequence nitinp82 UNIX for Dummies Questions & Answers 1 02-01-2007 04:40 PM
wierd sparc 5 dozy SUN Solaris 5 10-13-2003 11:45 AM
Wierd Message???? lesstjm UNIX for Dummies Questions & Answers 6 01-04-2002 10:01 AM

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 11-01-2007
amatheny amatheny is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 2
Wierd results with awk

Hey, I'm trying to use awk for some simple file manipulations but i'm getting soem wierd results.

So i want to open up a file which looks like this:

@relation 'autoMpg'
@attribute a numeric
@attribute b numeric
@attribute c numeric
@data
-1.170815,0.257522,0.016416
-1.335653,0.30494,0.009793
-1.227306,0.300442,0.024001

and remove everything except the data, with tabs delimiting the values.

I'm using the following awk script.

gawk ' {OFS="\t"} data { print $1 $2 $3} /@data/ {data = 1} ' autoMpg-3d.arff > tmp.dat

However, no matter what value I enter for OFS, I still always get output like this:

-1.170815,0.257522,0.016416
-1.335653,0.30494,0.009793
-1.227306,0.300442,0.024001

with commas delimiting the values.

Does anyone know whats going on here?
  #2 (permalink)  
Old 11-01-2007
RacerX's Avatar
RacerX RacerX is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 38
Looks like you did not specify a Field Separator just the Output Field Separator you wanted. Sorry i don't have gawk but in Awk is this close to what you were trying to do?
Code:
awk 'BEGIN {FS = ","; OFS="\t"} data { print $1, $2, $3} /@data/ {data = 1} ' ~/Desktop/datainput.txt > ~/Desktop/test.txt

OUTPUT RETURNED:
-1.170815	0.257522	0.016416
-1.335653	0.30494	    0.009793
-1.227306	0.300442	0.024001
  #3 (permalink)  
Old 11-01-2007
amatheny amatheny is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 2
Thanks, that fixed it.

I had to use awk instead of awk though. wierd.
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 08:43 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