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
extract a line from a file using the line number grandtheftander Shell Programming and Scripting 7 01-22-2009 10:24 AM
AWK - if last line/record do something PacificWonder Shell Programming and Scripting 3 06-06-2008 12:13 AM
Extract a line from a file using the line number zambo Shell Programming and Scripting 1 05-01-2008 02:39 PM
Using sed to extract Nth record? doubleminus UNIX for Dummies Questions & Answers 3 04-19-2008 11:18 AM
How to extract duplicate records with associated header record run_eim UNIX for Dummies Questions & Answers 17 01-16-2007 11:46 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 10-12-2005
bjorb bjorb is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 12
extract specific data from file and insert into new file.

Hi all!!

After experiencing great helpfulness the last time I posted a problem at this site, I once again turn to the forum for expert help.

The problem:

I have a file.dat containing x, y, and z coordinates, like:

x y z
1 1 4
1 2 3
1 3 9

2 1 7
2 2 2
2 3 8

3 1 3
3 2 5
3 3 7

.....and so on.

I would like to extract the maximum z value with its respective x value from each data block and insert these values into a filenew.dat:

Example:

file.dat

1 1 9 #extract this
1 2 3
1 3 2

2 1 7
2 2 2
2 3 8 #extract this

3 1 3
3 2 7 #extract this
3 3 5

and insert into....

filenew.dat
1 9
2 8
3 7


Already greatful for previous assistance, I humbly ask:
Could anybody help me with this?

Regards
bjorb
  #2 (permalink)  
Old 10-12-2005
krhamidou's Avatar
krhamidou krhamidou is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 27
maybe you should try to use awk ? i'm sorry , i haven't programmed using awk for a long time but this is a little tutorial about awk.
  #3 (permalink)  
Old 10-13-2005
bjorb bjorb is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 12
Thanks for the link.
But to be honest I'm not to familiar with awk myself.
Is there a way to pick a max value from a field using awk?

Could grep be used?

bjorb
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 11:42 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