Uniq command behaving odd


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Uniq command behaving odd
# 1  
Old 02-18-2010
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
k
d
f
j
l
k
s
a
d
j
f
l
k
s
d
j
f
l

The result when i do is
$ cat a.txt |uniq -u
k
s
j
v
l
k
a
s
f
l
k
s
a
d
f
j
l
a
s
k
d
f
j
l
k
s
a
d
j
f
l
k
s
d
j
f
l


i was expecting for k ,s ... to be for only one time but it happens to be that they apper more than once
# 2  
Old 02-19-2010
Code:
$ cat a.txt | sort -u

# 3  
Old 02-19-2010
uniq command will work if the file is sorted one
so use sort command before using uniq command.
# 4  
Old 02-19-2010
ThnX Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

cut command Behaving Differnetly in different Version

Hi, We have few hundered scripts using cut command in thousands of lines. On HP-UX shell script developer used echo "ABCEFG" | cut -c -1-3 to cut first three character of the string. We recently moved to Linux and this command throws error. I think this might be due to different version of... (3 Replies)
Discussion started by: ajazurrahman
3 Replies

2. 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

3. Shell Programming and Scripting

jobs command behaving differently in script

Here is my test script: #!/bin/sh result=`jobs` echo " Jobs: "$result result=`ls` echo " LS "$result Here is the output: Jobs: LS 0 1 2 3 4 5 6 7 gcd initialize.sh #inter_round_clean.sh# inter_round_clean.sh inter_round_clean.sh~ look parallel_first_run.sh... (3 Replies)
Discussion started by: nealh
3 Replies

4. Shell Programming and Scripting

Grep command behaving strangely

Hi, I need to count number of '$' symbol in a file and assign it to a variable. I am using below command. grep -c '\$' inputfile O/p: 10359 Its giving correct o/p but when I am assigning the same to a variable its giving completely different o/p. ab1=`grep -c '\$' inputfile` $... (3 Replies)
Discussion started by: Opamps123
3 Replies

5. Shell Programming and Scripting

mail command behave odd

hi, The following mail cmd executed successfully. mailx -s 'subject' user@company.com < testfile.dat However When i include this mail cmd in shell script it behave odd. Getting an error message mailx comand not found. (2 Replies)
Discussion started by: zooby
2 Replies

6. UNIX for Advanced & Expert Users

Odd message from find command

Running the find command as: find /abc -follow -ls gives, for some files, the message, which I have never seen before: find: /abc/def/123.txt: No error Does it mean that find found the file with out error. If it found it without error then why did it not output the "ls" particulars as with... (2 Replies)
Discussion started by: twk
2 Replies

7. Shell Programming and Scripting

tr command behaving unexpectedly

Im trying to execute the below command on our server to list files and replace the newline in the file list with spaces, but the character 'n' is getting replaced with a space, is there any environment variable that needs to be set in UNIX? sh -c 'ls -trx... (1 Reply)
Discussion started by: rameshrr3
1 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. Shell Programming and Scripting

ksh - odd output from for command...

Help needed - I am sure there is something to do with tabs or white space that is killing me here.. I have a file that is generated from an oracle sql script - when I cat the file I see the below 601888725 14-AUG-08-10:20 3 601888726 14-AUG-08-10:37 ... (4 Replies)
Discussion started by: frustrated1
4 Replies

10. UNIX for Dummies Questions & Answers

awk command behaving differntly on 2 servers--urgent

Hi I am using awk command for string replacement. I have 2 servers. The command runs perfectly well on 1st server On the second server when i run the command on the same datset The command gets stuck while processing a large piece of record.. Does it have anything to with setting on the 2... (1 Reply)
Discussion started by: aixjadoo
1 Replies
Login or Register to Ask a Question