08-20-2007
remove duplicated lines without sort
Hi
Just wondering whether or not I can remove duplicated lines without sort
For example, I use the command who, which shows users who are logging on. In some cases, it shows duplicated lines of users who are logging on more than one terminal.
Normally, I would do
who | cut -d" " -f1 | sort |uniq
But I realised that I do not want data to be sorted.
Is there any other ways to do it?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi all,
i have a file contain multicolumns, this file is sorted by col2 and col3.
i want to remove the duplicated columns if the col2 and col3 are the same in another line.
example
fileA
AA BB CC DD
CC XX CC DD
BB CC ZZ FF
DD FF HH HH
the output is
AA BB CC DD
BB CC ZZ FF... (6 Replies)
Discussion started by: kamel.seg
6 Replies
2. Shell Programming and Scripting
Hi
having a file as follows
MediaErr.log
84 Server1 Policy1 Schedule1 master1 05/08/2008 02:12:16
84 Server1 Policy1 Schedule1 master1 05/08/2008 02:22:47
84 Server1 Policy1 Schedule1 master1 05/08/2008 03:41:26
84 Server1 Policy1 ... (1 Reply)
Discussion started by: karthikn7974
1 Replies
3. UNIX for Dummies Questions & Answers
Hello all,
I've got a strange behaviour of sort and uniq commands: they do not recognise apparently duplicated lines in a file (already sorted). The lines are identical by eye, but they must differ in smth, because when they are put in two files, those have slightly different size.
What can make... (8 Replies)
Discussion started by: roussine
8 Replies
4. Shell Programming and Scripting
Input file:
hcmv-US25-2-3p hsa-3160-5
hcmv-US33 hsa-47
hcmv-UL70-3p hsa-4508
hcmv-UL70-3p hsa-4486
hcms-US25 hsa-360-5
hcms-US25 hsa-4
hcms-US25 hsa-458
hcms-US25 hsa-44812
.
.
Desired Output file:
hcmv-US25-2-3p hsa-3160-5
hcmv-US33 hsa-47
hcmv-UL70-3p hsa-4508
hsa-4486... (3 Replies)
Discussion started by: perl_beginner
3 Replies
5. Shell Programming and Scripting
I have a csv file that I would like to remove duplicate lines based on field 1 and sort. I don't care about any of the other fields but I still wanna keep there data intact. I was thinking I could do something like this but I have no idea how to print the full line with this. Please show any method... (8 Replies)
Discussion started by: cokedude
8 Replies
6. UNIX for Dummies Questions & Answers
hello, I have a large file (about 1gb) that is in a file similar to the following:
I want to make it so that I can put all the duplicates where column 3 (delimited by the commas) are shown on top. Meaning all people with the same age are listed at the top.
The command I used was ... (3 Replies)
Discussion started by: jl487
3 Replies
7. Shell Programming and Scripting
Hi, if i have a file like this:
Query=1
a
a
b
c
c
c
d
Query=2
b
b
b
c
c
e
.
.
. (7 Replies)
Discussion started by: the_simpsons
7 Replies
8. Shell Programming and Scripting
In a folder I'll several times daily receive new files that I want to combine into one big file, without any duplicate rows.
The file name in the folder will look like e.q:
MissingData_2014-08-25_09-30-18.txt
MissingData_2014-08-25_09-30-14.txt
MissingData_2014-08-26_09-30-12.txt
The content... (9 Replies)
Discussion started by: Bergans
9 Replies
9. Shell Programming and Scripting
Hi, all
I have a csv file that I would like to remove duplicate lines based on 1st field and sort them by the 1st field. If there are more than 1 line which is same on the 1st field, I want to keep the first line of them and remove the rest. I think I have to use uniq or something, but I still... (8 Replies)
Discussion started by: refrain
8 Replies
10. AIX
Hello.
I have a server with 2 boot disk but in the bootlist there are 5 paths of one disk but no path of the other.
How can I remove paths from one disk to insert paths from the other disk?
Thanks in advance.
server074:root:/# bootlist -om normal
hdisk0 blv=hd5 pathid=0
hdisk0... (7 Replies)
Discussion started by: Gabriander
7 Replies
LEARN ABOUT ULTRIX
ruptime
ruptime(1c) ruptime(1c)
Name
ruptime - show host status of local machines
Syntax
ruptime [ options ] [ machinename ]
Description
The command gives a status line like for each machine on the local network. If a machinename is given, the status of only the named
machine is given. These status lines are formed from packets broadcast by each host on the network once a minute.
Machines for which no status report has been received for 5 minutes are shown as being down.
Options
-a Users idle an hour or more are not counted unless this option is specified.
-d Display only those hosts that are considered down.
-l Sort the status list by load average. If more than one sort option is given, uses the last one.
-r Show only hosts that are up and running.
-t Sort the status list by uptime. If more than one sort option is given, uses the last one.
-u Sort the status list by number of users. If more than one sort option is given, uses the last one.
-nn Show only those hosts with nn or more users.
Restrictions
Because the daemon sends its information in broadcast packets it generates a large amount of network traffic. On large networks the extra
traffic may be objectionable. Therefore, the daemon is disabled by default. To make use of the daemon for both the local and remote
hosts, remove the comment symbols (#) from in front of the lines specifying in the file.
If the daemon is not running on a remote machine, the machine may incorrectly appear to be down when you use the command to determine its
status. See the reference page for more information.
If a system has more than 40 users logged in at once, the number of users displayed by the command is incorrect. Users who login to a
machine after that point fail to increment the user count that appears in the output of the command. This is due to the maximum size limit
of an Ethernet packet, which is 1500 bytes, and the fact that the daemon must broadcast its information in a single packet.
Files
/usr/spool/rwho/whod.* Information about other machines
See Also
rwho(1c), rwhod(8c)
ruptime(1c)