|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Command line / script option to filter a data set by values of one column
Hi all!
I have a data set in this tab separated format : Label, Value1, Value2 An instance is "data.txt" : 0 1 1 -1 2 3 0 2 2 I would like to parse this data set and generate two files, one that has only data with the label 0 and the other with label -1, so my outputs should be, for example : data0.txt 0 1 1 0 2 2 and data-1.txt -1 2 3 These are large datasets, and I do not know in advance how many labels there are. Assuming the labels are l1...ln, I would like the outputs stored in data_<label>.txt where <label> is one of l1...ln Can someone here suggest a quick way to script / command-line this? Thanks in advance! |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
awk '{file="data"$1".txt";print $0 > file}' data.txtuse code tag for posting the data and scripts http://www.unix.com/how-post-unix-li...code-tags.html |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading command line arguments and setting up values if option not provided | kristinu | Programming | 2 | 03-22-2012 09:16 PM |
| What is a menu or command line option driven script? | kpddong | UNIX for Dummies Questions & Answers | 2 | 12-09-2010 11:58 AM |
| Filter and migrate data from row to column | shah09 | Shell Programming and Scripting | 5 | 05-31-2010 08:24 AM |
| How to change values in certain column only in every line (any script) | luna_soleil | Shell Programming and Scripting | 3 | 05-17-2010 12:45 PM |
| repeated column data filter and make as a row | vasanth_vadalur | Shell Programming and Scripting | 2 | 06-16-2009 07:01 AM |
|
|