![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| adding values with a loop | hcclnoodles | Shell Programming and Scripting | 1 | 05-27-2008 03:42 AM |
| How to use array values after the loop. | Devesh5683 | Shell Programming and Scripting | 1 | 05-13-2008 04:38 PM |
| getting values from variable in a loop | kriuz | Shell Programming and Scripting | 3 | 01-22-2008 02:50 PM |
| Help In Calculation of large values in loop | sandeepb | Shell Programming and Scripting | 6 | 09-13-2007 05:02 AM |
| select distinct row from a file | merry susana | UNIX for Dummies Questions & Answers | 7 | 05-03-2005 03:54 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Loop through only the distinct values in a file
Datafile has the following data seperated by :
FIELD1:FIELD2:FIELD3 D1:/opt/9.1.9:Y D2:/opt/10.1.10:Y D3:/opt/9.1.9:Y D4:/opt/8.1.8:Y D5:/opt/8.1.8:Y D6:/opt/9.1.9:Y D7:/opt/9.1.9:Y D8:/opt/10.1.10:Y D9:/opt/9.1.9:Y D10:/opt/10.1.10:Y I want to do some operations only on the distinct values of FIELD2 in a loop. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
#3
|
|||
|
|||
|
you have to be more specific here.. assuming this file is delimited by colons, u can get the distinct values by cut -f2 -d':' filename and pipe output to | sort | uniq
if u want it in loop the u can use for i in `cut -f2 -d':' filenmae |sort|uniq` do ls -l $i #do something done its untested code so u may hv to tweak a little |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|