Uniq Command?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Uniq Command?
# 8  
Old 11-30-2010
Nicely alphabetically sorted
Code:
awk -F'[@:]' '{print $2}' infile | sort -u

Code:
sed 's\@\\;s\:.*\\' infile | sort -u

No sort:
Code:
awk -F'[@:]' '!A[$2]++{print $2}' infile


Last edited by Scrutinizer; 11-30-2010 at 05:28 AM..
# 9  
Old 11-30-2010
Code:
# sed -n 's/^@//;s/:.*//p' infile | sed -e :x -e 'N;s/\(.*\)\n\1/ \1/' -e 'tx'|sed 's/  */\n/g;s/^\n//g'

# 10  
Old 11-30-2010
Just saw the same command already given.

Code:
awk -F"[@:]" '!a[$2]++{print $2}' infile

# 11  
Old 11-30-2010
Code:
 
awk -F"[@:]" '!_[$2]++{print $2}' infile

...Edit...
oh...i didn't see the replies on the second page. My bad!!!
# 12  
Old 11-30-2010
Thanks, I got all the car makes put into a selection box! I want people to be able to pick a make and then pick an option. For example: Select Audi in the selection box and then have the options (warranty, price, color) in checkboxes.

I need the script to pull out the options from the file, they can't be hard coded. All the options follow the ":" For example:
@Audi:Warranty (Warranty is the option)

Thanks
# 13  
Old 11-30-2010
Something like this?
Code:
awk -F'[@:]' '$2==b{print $3}' b=Audi infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trying to find the distinct lines using uniq command

Platform :Oracle Linux 6.4 Shell : bash The below file has 7 lines , some of them are duplicates. There are only 3 distinct lines. But why is the uniq command still showing 7 ? I just want the distinct lines to be returned. $ cat test.txt SELECT FC.COORD_SET_ID FROM OM_ORDER_FLOW F, -... (2 Replies)
Discussion started by: kraljic
2 Replies

2. Shell Programming and Scripting

cat and uniq command

Hello i have tried to retrieve a distinct list of data from a file with a command combination but the uniq command line is not filtering the fields repeated. Can someone help me ? here is the file input 3837734|LAUNCH TEST01 3837735|LAUNCH TEST01 3837736|LAUNCH TEST01 3837737|LAUNCH... (4 Replies)
Discussion started by: ade05fr
4 Replies

3. Shell Programming and Scripting

Addition as part of uniq command

Dear Friends, I want to know if it is possible to perform addition as part of uniq command. Input: 213.64.56.208 1 213.64.56.208 2 213.64.56.208 3 213.46.27.204 10 213.46.27.204 20 213.46.27.204 30 The above input should be converted as follows 213.64.56.208 6 213.46.27.204 60 ... (4 Replies)
Discussion started by: tamil.pamaran
4 Replies

4. UNIX for Dummies Questions & Answers

Re: How To Use UNIQ UNIX Command On single Column

Hi , Can You Please let Know How use unix uniq command on a single column for deleting records from file with Below Structure.Pipe Delimter File . Source Name | Account_Id A | 101 B... (2 Replies)
Discussion started by: anudeepkumar123
2 Replies

5. UNIX for Advanced & Expert Users

uniq command

at which situation uniq command fails. How to delete/remove duplicate lines in an unix file (1 Reply)
Discussion started by: tp2115
1 Replies

6. UNIX for Dummies Questions & Answers

Several file comparison not uniq or comm command

When comparing several files is there a way to find values unique to each file? File1 a b c d File2 a b t File 3 a (3 Replies)
Discussion started by: dr_sabz
3 Replies

7. UNIX for Dummies Questions & Answers

Uniq command behaving odd

My file has k s j v l k a s f l k s a d f j l a s (3 Replies)
Discussion started by: phoenix_nebula
3 Replies

8. Shell Programming and Scripting

Help with uniq command

I call.... cat 1.txt | uniq -c Sample of whats in 1.txt vmstat cd exit w cd cd cd newgrp xinit f cd cd cd rlogin (2 Replies)
Discussion started by: Bandit390
2 Replies

9. UNIX for Dummies Questions & Answers

Difference between plain "uniq" and "uniq -u"

Dear all, It's not entirely clear to me from manpage the difference between them. Why we still need "-u" flag? - monkfan (3 Replies)
Discussion started by: monkfan
3 Replies

10. UNIX for Dummies Questions & Answers

uniq command???

HI, Please tell the usage of uniq command in UNIX with example Thanks (2 Replies)
Discussion started by: skyineyes
2 Replies
Login or Register to Ask a Question