Sponsored Content
Top Forums Shell Programming and Scripting Remove duplicate lines, sort it and save it as file itself Post 302941024 by RudiC on Saturday 11th of April 2015 06:29:42 AM
Old 04-11-2015
We would know the failure reasons even less than you do as we don't see your results as you see them. Why shouldn't head and tail work for you? Did you run them individually, trying to figure out how they work and how they cooperate to give the results you need?

man sort would show you the -u option to keep only unique key values, although it is not guaranteed that those will be the respective first line that occurred. You'd need a compound statement with awk and sort to get what you want.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove Duplicate Lines in File

I am doing KSH script to remove duplicate lines in a file. Let say the file has format below. FileA 1253-6856 3101-4011 1827-1356 1822-1157 1822-1157 1000-1410 1000-1410 1822-1231 1822-1231 3101-4011 1822-1157 1822-1231 and I want to simply it with no duplicate line as file... (5 Replies)
Discussion started by: Teh Tiack Ein
5 Replies

2. UNIX for Dummies Questions & Answers

Remove Duplicate lines from File

I have a log file "logreport" that contains several lines as seen below: 04:20:00 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but responded to ping 06:38:08 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but responded to ping 07:11:05 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but... (18 Replies)
Discussion started by: Nysif Steve
18 Replies

3. UNIX for Dummies Questions & Answers

How to delete or remove duplicate lines in a file

Hi please help me how to remove duplicate lines in any file. I have a file having huge number of lines. i want to remove selected lines in it. And also if there exists duplicate lines, I want to delete the rest & just keep one of them. Please help me with any unix commands or even fortran... (7 Replies)
Discussion started by: reva
7 Replies

4. Shell Programming and Scripting

Sort and Remove Duplicate on file

How do we sort and remove duplicate on column 1,2 retaining the record with maximum date (in feild 3) for the file with following format. aaa|1234|2010-12-31 aaa|1234|2010-11-10 bbb|345|2011-01-01 ccc|346|2011-02-01 bbb|345|2011-03-10 aaa|1234|2010-01-01 Required Output ... (5 Replies)
Discussion started by: mabarif16
5 Replies

5. Shell Programming and Scripting

remove duplicate lines from file linux/sh

greetings, i'm hoping there is a way to cat a file, remove duplicate lines and send that output to a new file. the file will always vary but be something similar to this: please keep in mind that the above could be eight occurrences of each hostname or it might simply have another four of an... (2 Replies)
Discussion started by: crimso
2 Replies

6. Shell Programming and Scripting

How do I remove the duplicate lines in this file?

Hey guys, need some help to fix this script. I am trying to remove all the duplicate lines in this file. I wrote the following script, but does not work. What is the problem? The output file should only contain five lines: Later! (5 Replies)
Discussion started by: Ernst
5 Replies

7. Shell Programming and Scripting

Remove duplicate lines from a 50 MB file size

hi, Please help me to write a command to delete duplicate lines from a file. And the size of file is 50 MB. How to remove duplicate lins from such a big file. (6 Replies)
Discussion started by: vsachan
6 Replies

8. Shell Programming and Scripting

How to remove blank lines in a file and save the file with same name?

I have a text file which has blank lines. I want them to be removed before upload it to DB using SQL *Loader. Below is the command line, i use to remove blank lines. sed '/^ *$/d' /loc/test.txt If i use the below command to replace the file after removing the blank lines, it replace the... (6 Replies)
Discussion started by: vel4ever
6 Replies

9. Shell Programming and Scripting

Remove duplicate lines based on field and sort

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

10. Shell Programming and Scripting

Remove duplicate lines from a file

Hi, I have a csv file which contains some millions of lines in it. The first line(Header) repeats at every 50000th line. I want to remove all the duplicate headers from the second occurance(should not remove the first line). I don't want to use any pattern from the Header as I have some... (7 Replies)
Discussion started by: sudhakar T
7 Replies
DBIPROF(1)						User Contributed Perl Documentation						DBIPROF(1)

NAME
dbiprof - command-line client for DBI::ProfileData SYNOPSIS
See a report of the ten queries with the longest total runtime in the profile dump file prof1.out: dbiprof prof1.out See the top 10 most frequently run queries in the profile file dbi.prof (the default): dbiprof --sort count See the same report with 15 entries: dbiprof --sort count --number 15 DESCRIPTION
This tool is a command-line client for the DBI::ProfileData. It allows you to analyze the profile data file produced by DBI::ProfileDumper and produce various useful reports. OPTIONS
This program accepts the following options: --number N Produce this many items in the report. Defaults to 10. If set to "all" then all results are shown. --sort field Sort results by the given field. Sorting by multiple fields isn't currently supported (patches welcome). The available sort fields are: total Sorts by total time run time across all runs. This is the default sort. longest Sorts by the longest single run. count Sorts by total number of runs. first Sorts by the time taken in the first run. shortest Sorts by the shortest single run. key1 Sorts by the value of the first element in the Path, which should be numeric. You can also sort by "key2" and "key3". --reverse Reverses the selected sort. For example, to see a report of the shortest overall time: dbiprof --sort total --reverse --match keyN=value Consider only items where the specified key matches the given value. Keys are numbered from 1. For example, let's say you used a DBI::Profile Path of: [ DBIprofile_Statement, DBIprofile_Methodname ] And called dbiprof as in: dbiprof --match key2=execute Your report would only show execute queries, leaving out prepares, fetches, etc. If the value given starts and ends with slashes ("/") then it will be treated as a regular expression. For example, to only include SELECT queries where key1 is the statement: dbiprof --match key1=/^SELECT/ By default the match expression is matched case-insensitively, but this can be changed with the --case-sensitive option. --exclude keyN=value Remove items for where the specified key matches the given value. For example, to exclude all prepare entries where key2 is the method name: dbiprof --exclude key2=prepare Like "--match", If the value given starts and ends with slashes ("/") then it will be treated as a regular expression. For example, to exclude UPDATE queries where key1 is the statement: dbiprof --match key1=/^UPDATE/ By default the exclude expression is matched case-insensitively, but this can be changed with the --case-sensitive option. --case-sensitive Using this option causes --match and --exclude to work case-sensitively. Defaults to off. --delete Sets the "DeleteFiles" option to DBI::ProfileData which causes the files to be deleted after reading. See DBI::ProfileData for more details. --dumpnodes Print the list of nodes in the form of a perl data structure. Use the "-sort" option if you want the list sorted. --version Print the dbiprof version number and exit. AUTHOR
Sam Tregar <sam@tregar.com> COPYRIGHT AND LICENSE
Copyright (C) 2002 Sam Tregar This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. SEE ALSO
DBI::ProfileDumper, DBI::Profile, DBI. perl v5.18.2 2018-09-13 DBIPROF(1)
All times are GMT -4. The time now is 10:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy