Sponsored Content
Top Forums Shell Programming and Scripting Shell script to remove duplicates lines in a file Post 302291492 by RichElks on Wednesday 25th of February 2009 08:47:06 PM
Old 02-25-2009
Shell script to remove duplicates lines in a file

Hi,

I am writing a shell script that needs to remove duplicate lines within a file by category.
example:
section a
a
c
b
a
section b
a
b
a
c

I need to remove the duplicates within th category with out removing the duplicates from the 2 different sections (one of the a's in section a, and one of the a's in section b).

I wanted to use uniq but i have to sort the file first...which takes the lines out of the sections they are supposed to be in and sorts the entire file which I don't want.....but I wouldn't mind sorting it by category if possible.

any help is appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script: Remove blank lines

Hi gurus, I have this file with blank lines in it. How do i remove them in shell? I tried these commands but not working: sed '/^ *$/d' or sed '/^$/d' Anybody has a better idea pls? Also there are lines which starts with a single space, how do we remove the space in those lines?... (3 Replies)
Discussion started by: gholdbhurg
3 Replies

2. Shell Programming and Scripting

shell script to remove all lines from a file before a line starting with pattern

hi,, i hav a file with many lines.i need to remove all lines before a line begginning with a specific pattern from the file because these lines are not required. Can u help me out with either a perl script or shell script example:- if file initially contains lines: a b c d .1.2 d e f... (2 Replies)
Discussion started by: raksha.s
2 Replies

3. Shell Programming and Scripting

How to delete lines in a file that have duplicates or derive the lines that aper once

Input: a b b c d d I need: a c I know how to get this (the lines that have duplicates) : b d sort file | uniq -d But i need opossite of this. I have searched the forum and other places as well, but have found solution for everything except this variant of the problem. (3 Replies)
Discussion started by: necroman08
3 Replies

4. Shell Programming and Scripting

need Shell script for Sort BASED ON FIRST FIELD and PRINT THE WHOLE FILE WITHOUT DUPLICATES

Can some one provide me a shell script. I have file with many columns and many rows. need to sort the first column and then remove the duplicates records if exists.. finally print the full data with first coulm as unique. Sort BASED ON FIRST FIELD and remove the duplicates if exists... (2 Replies)
Discussion started by: tuffEnuff
2 Replies

5. Shell Programming and Scripting

Script to remove duplicates

Hi I need a script that removes the duplicate records and write it to a new file for example I have a file named test.txt and it looks like abcd.23 abcd.24 abcd.25 qwer.25 qwer.26 qwer.98 I want to pick only $1 and compare with the next record and the output should be abcd.23... (6 Replies)
Discussion started by: antointoronto
6 Replies

6. Shell Programming and Scripting

How to remove some xml tag lines using shell script

I have existing XML file as below, now based on input string in shell script on workordercode i need to create a seprate xml file for e.g if we pass the input string as 184851 then it find the tag data from <workOrder>..</workOrder> and write to a new file and similarly next time if i pass the... (3 Replies)
Discussion started by: balrajg
3 Replies

7. UNIX for Dummies Questions & Answers

script to remove duplicates per line

Hello experts! I'd like a way to remove duplicates per line. Strings are enclosed in brackets, and I would prefer to maintain the order of the file: example input (56)(63) (56)(70)(56)(70)(24) (25)(78) (12)(33)(12) (10) (10) desired output (56)(63) (56)(70)(24) (25)(78)... (5 Replies)
Discussion started by: torchij
5 Replies

8. UNIX for Dummies Questions & Answers

Remove duplicates lines in a files

I have a file called FILE cat FILE 11/11/2012 11/11/2012 12/11/2012 15/11/2012 need to remove the duplicates dates ( ie 11/11/2012 is present two times i need remove one duplicates date ) Need outputs like this 11/11/2012 12/11/2012 15/11/2012 I have tried using awk... (8 Replies)
Discussion started by: Venkatesh1
8 Replies

9. Shell Programming and Scripting

How can I remove some xml tag lines using shell script?

Hi All, My name is Prathyu and I am working as a ETL develper. I have one requirement to create a XML file based on the provided XSD file. As per the Datastage standards Key(repeatable) field does not contain any Null values so I am inserting some dummy tag line to that XML file. ... (14 Replies)
Discussion started by: Prathyu
14 Replies

10. Shell Programming and Scripting

How to remove duplicates in C shell Array?

Please help me on this My script name is uniqueArray.csh #!/bin/csh set ARRAY = ( one teo three one three ) set ARRAY = ( $ARRAY one five three five ) How to remove the duplicates in this array ,sort and save those in the same variable or different variable. Thanks in the advance ... (3 Replies)
Discussion started by: SA_Palani
3 Replies
size(1) 						      General Commands Manual							   size(1)

NAME
size - print section sizes of object files SYNOPSIS
files DESCRIPTION
produces section size information for each section in the object files. The size of the text, data and bss (uninitialized data) sections are printed along with the total size of the object file. If an archive file is input to the command, the information for all archive mem- bers is displayed. Options recognizes the following options: Print sizes in decimal. This is the default. Print sizes in octal. Print sizes in hexadecimal. Print version information about the command. Print a verbose list of the subspaces in the object files. Each subspace is listed on a separate line with its size, physical address, and virtual address. Print the size of each allocatable section (ELF only). Print the size and permission bits of each loadable segment (ELF only). Print the sizes of non loadable segments or non allocatable sections (ELF only). Print the usage menu. EXTERNAL INFLUENCES
Environment Variables The following internationalization variables affect the execution of Determines the locale category for native language, local customs and coded character set in the absence of and other environment variables. If is not specified or is set to the empty string, a default of (see lang(5)) is used instead of Determines the values for all locale categories and has precedence over and other environment variables. Determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error. Determines the locale category for numeric formatting. Determines the locale category for character handling functions. Determines the location of message catalogues for the processing of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to See envi- ron(5). International Code Set Support Single- and multi-byte character code sets are supported. DIAGNOSTICS
name cannot be read. name is not an appropriate object file. EXAMPLES
Compare the sizes of the text, data, and bss sections for two versions of a program: SEE ALSO
System Tools: as(1) translate assembly code to machine code cc(1) invoke the HP-UX C compiler ld(1) invoke the link editor Miscellaneous: a.out(4) assembler, compiler, and linker output ar(4) archive format STANDARDS CONFORMANCE
size(1)
All times are GMT -4. The time now is 12:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy