sorting doubt


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sorting doubt
# 1  
Old 11-21-2008
sorting doubt

HI,
I would like to know if there if any sorting command which uniquifies the list but does not arrange in alphabetical order.
ex- I have
b
b
a
b

Output I want is :
b
a

I am trying sort -u and this does the sorting in alphabetical order.

Please help friends
# 2  
Old 11-21-2008
Quote:
Originally Posted by abhishekarun123
HI,
I would like to know if there if any sorting command which uniquifies the list but does not arrange in alphabetical order.
ex- I have
b
b
a
b

Output I want is :
b
a

I am trying sort -u and this does the sorting in alphabetical order.

Please help friends
Are you open to awk ? If so, try

Code:
awk '!x[$1]++' list.txt

# 3  
Old 11-21-2008
It is not working for me. Is that an unix xommand ?
Any other suggestion?
# 4  
Old 11-21-2008
Yes:
Code:
perl -ne'print unless $_{$_}++'

Could you clarify what's wrong with the awk solution?
# 5  
Old 11-21-2008
thanks !!

when I used that command i got an error as : x[: Event not found.
perhaps i am using it wrongly, its new to me ..
# 6  
Old 11-21-2008
Quote:
Originally Posted by abhishekarun123
thanks !!

when I used that command i got an error as : x[: Event not found.
perhaps i am using it wrongly, its new to me ..
The problem is that you're using a C shell, try running the command from another shell.

Last edited by radoulov; 11-21-2008 at 08:17 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Doubt..

Hi experts, In one of our code we have used some command like this. name=${name##*/} Can someone please let me know what exactly it does? Thanks & Regards, Sathya V. (1 Reply)
Discussion started by: Sathya83aa
1 Replies

2. Ubuntu

Doubt

hi ,, i am new for this.. i want to know abt linux os.. which version is best for it industry.. please suggest me..:cool: (1 Reply)
Discussion started by: c vignesh kumar
1 Replies

3. Red Hat

doubt

I need help in opening the .exe files in linux. As i have downloaded ubuntu os from trail version. after executing the the file name in terminal it is stating that get archive files for opening the .exe files. But i am unable to get it please help me (2 Replies)
Discussion started by: yashwanthguru
2 Replies

4. UNIX for Dummies Questions & Answers

Doubt

Hi , Struck with one basic question. Iam expecting word count of 4 where "wc" is showing as 5 . # echo "abcd" | wc 1 1 5 # echo abcd | wc 1 1 5 (5 Replies)
Discussion started by: penchal_boddu
5 Replies

5. Shell Programming and Scripting

Doubt??

I jus want to know the meaning of the below command line(exclamation following that re-direction) sqlplus -s `cat /home/sample.txt` <<! Thanks!! (1 Reply)
Discussion started by: nohup
1 Replies

6. Shell Programming and Scripting

One doubt

Hi, Can i use the shell script like this? When i am running the script it is hanging not giving me any output. I can redirect the output and then i can do the manipulations also but why this one is wrong. I am confused we can do like this or not.. #!/usr/bin/ksh for line in `top` do... (2 Replies)
Discussion started by: namishtiwari
2 Replies

7. UNIX for Dummies Questions & Answers

doubt on name

HI, Iam jus tin a confusion that solaris and unix are the same.if they are diffrent,how they are?pls give me a brief idea abt these two. I will be very grateful to you thanks (1 Reply)
Discussion started by: shruti_mgp
1 Replies
Login or Register to Ask a Question