Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 5th July 2012, 07:48 AM
papori Offline
Registered User
 
Join Date: Nov 2010
Posts: 58
linuxfedorafirefox
split my file

Hi all,
i am looking for a way to split file into 4 groups.
my file looks like:
c0 c1 c2 c3
name1 1 3 5
name2 144 36 53
name3 14 10 7
name4 11 12 8

Tab is separate between fields.
i want group1 to be all names where c1>c2>c3
the result should be name3
group2 to be c1<c2<c3
result name1
group3 to be c1>c2<c3
result name2
group4 to be c1<c2>c3
result name4

Any idea of easy way?
Perl/bash..

Thanks,
Pap
Reply With Quote
  #2  
Old 5th July 2012, 10:29 AM
flyingfsck Offline
Registered User
 
Join Date: Aug 2010
Location: Al Ain, UAE
Posts: 1,046
linuxfirefox
Re: split my file

Easy way?

$ gnumeric filename
Reply With Quote
  #3  
Old 5th July 2012, 01:04 PM
papori Offline
Registered User
 
Join Date: Nov 2010
Posts: 58
linuxchrome
Re: split my file

Thanks,
that is easy..
But, what if i have 100 files?
Reply With Quote
  #4  
Old 5th July 2012, 01:17 PM
flyingfsck Offline
Registered User
 
Join Date: Aug 2010
Location: Al Ain, UAE
Posts: 1,046
linuxfirefox
Re: split my file

Write a gnumeric macro!
Reply With Quote
  #5  
Old 5th July 2012, 01:47 PM
mrbrown79 Offline
Registered User
 
Join Date: Jul 2009
Posts: 45
linuxfirefox
Re: split my file

Quote:
Originally Posted by papori View Post
Hi all,
i am looking for a way to split file into 4 groups.
my file looks like:
c0 c1 c2 c3
name1 1 3 5
name2 144 36 53
name3 14 10 7
name4 11 12 8

Tab is separate between fields.
i want group1 to be all names where c1>c2>c3
the result should be name3
group2 to be c1<c2<c3
result name1
group3 to be c1>c2<c3
result name2
group4 to be c1<c2>c3
result name4

Any idea of easy way?
Perl/bash..

Thanks,
Pap
awk should be able to do that. E.g.

awk '{if($2>$3 && $3>$4) print $1 >> "group1.txt";if($2<$3 && $3<$4) print $1 >> "group2.txt" }' yourfile.txt
Reply With Quote
  #6  
Old 6th July 2012, 12:58 PM
george_toolan Offline
Registered User
 
Join Date: Dec 2006
Posts: 1,718
linuxfirefox
Re: split my file

Please note that the case "=" isn't handled, so if you have any lines with c1 == c2 or c2 == c3 they won't appear in any of the output files.
Reply With Quote
Reply

Tags
file, split

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
split or divide a text file into two files defined by percent mystical dervis Programming & Packaging 3 13th June 2007 05:39 PM
how to split .zip file thisObject Using Fedora 4 12th May 2007 06:06 AM
Need to split Jongi Servers & Networking 0 3rd April 2007 09:40 PM


Current GMT-time: 22:51 (Saturday, 18-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat