LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-11-2007, 07:21 PM   #1
Yogiz
LQ Newbie
 
Registered: Dec 2005
Posts: 13

Rep: Reputation: 0
Data manipulation


Hi there,

I have a bit of a problem with data manipulation below is the output, would it be possible to use a joint command or anything else to produce output file where the numbers in the middle columns mach each other like the first record in the input file.

Code:
Input
=============================
0.918	100	100	1.32
0.918	101	102	1.328
0.926	102	104	1.336
0.926	103	106	1.344
0.934	104	108	1.352
0.934	105	110	1.36
0.942	106	112	1.368
0.942	107	114	1.376
0.95	108	116	1.384
0.95	109	118	1.392
0.958	110	120	1.4
0.958	111	122	1.408
0.966	112	124	1.416
0.966	113	126	1.424
0.974	114	128	1.432
0.974	115	130	1.44
0.982	116	132	1.448
0.982	117	134	1.456
0.99	118	136	1.464
0.99	119	138	1.472
0.998	120	140	1.48

Output
==============================
0.918	100	100	1.32
0.918	101
0.926	102     102	1.328
0.926	103
0.934	104
0.934	105
0.942	106     106	1.344
Thanks in advance.

Last edited by Yogiz; 12-11-2007 at 07:27 PM.
 
Old 12-11-2007, 08:41 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I can't see the logic based on what you have shown. At first I thought you meant "write the line to output if cols 2 and 3 are the same".

You will need to describe the logic (algorithm) in more detail.
 
Old 12-11-2007, 09:00 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,414
Blog Entries: 4

Rep: Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836Reputation: 3836
There's more than one way to do it, obviously. (Hope I don't sound too much like a Perl-conversant programmer when I say that.) And there are several very powerful tools you can consider.

For example, in any Unix/Linux environment you can use the notion of "piping the output of one program into another" to do things like sorting your input and then processing it. Lots of programs know how to "accept input from STDIN and send it to STDOUT."

One very powerful tool is awk (see: man tt) which is specifically designed for dealing with text files. It is based on a disarmingly-simple premise that is astonishingly useful and powerful.

A step up from that is Perl, a genuine programming-language that is somewhat of "awk on super-steroids."

Start by considering your problem: describe it in terms of an algorithm that can be applied in order to solve it. In Linux/Unix, it is not a question of lacking for the tools to get the job done! The question is merely, how you wish to go about doing it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
String manipulation in C xeon123 Programming 2 10-17-2007 02:17 PM
String manipulation Manuel Alvarado Linux - Newbie 2 09-06-2006 10:49 PM
file name manipulation chocolatetoothpaste Linux - Software 19 04-03-2006 11:18 AM
[C/C++] Image manipulation Cornholio Programming 2 03-06-2005 12:46 PM
help with data manipulation SeT Programming 2 10-20-2004 08:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration