Removing duplicates on a single "column" (delimited file)
Hello !
I'm quite new to linux but haven't found a script to do this task, unfortunately my knowledge is quite limited on shellscripts...
Could you guys help me removing the duplicate lines of a file, based only on a single "column"?
For example:
So, the yellow field is found duplicate on a few lines... Like the first and last ones. But the data between them are different many times.
It doesn't matter for my purpose to have the ocurrence twice, even if the info before and after is different... So what I need is a script (maybe awk or cut) that recognizes the same string on position 8 and, if it was already found before, delete that whole line, but keep every other lines that do not contain a repeated string at position 8.
Ideas?
Last edited by jim mcnamara; 01-28-2016 at 04:15 PM..
Reason: code tags
I prefer the awk solutions suggested by Jim McNamara and MadeInGermany for your stated problem, but you could also consider this alternative for cases where you want the output sorted on the field you're using to select records:
which, with your sample input in oldfile, produces the output:
in newfile.
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi!
I am having 02 files.
In first file" X" I am having 02 Columns
TCP-5100 Sybase_5100
TCP-5600 Sybase_5600
Second file "Y" for example--
:services (
:AdminInfo (
:chkpf_uid ("{A2F79713-B67D-4409-83A4-A90804E983E9}")
:ClassName (rule_services)
)
:compound ()... (12 Replies)
Hi, all, I have a file that looks like:
## XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
## YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
#AA AB AC AD AE AF AG AH AI AJ AK AL
20 60039 60039 ... (5 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi guys,Got a bit of a bind I'm in. I'm looking to remove duplicates from a pipe delimited file, but do so based on 2 columns. Sounds easy enough, but here's the kicker...
Column #1 is a simple ID, which is used to identify the duplicate.
Once dups are identified, I need to only keep the one... (2 Replies)
Hi folks,
I have a log file in the below format and trying to get the output of the unique ones based on mnemonic IN PERL.
Could any one please let me know with the code and the logic ?
Severity Mnemonic Log Message
7 CLI_SCHEDULER Logfile for scheduled CLI... (3 Replies)
Hi,
I am on a Solaris8 machine
If someone can help me with adjusting this awk 1 liner (turning it into a real awkscript) to get by this "event not found error"
...or
Present Perl solution code that works for Perl5.8 in the csh shell ...that would be great.
******************
... (3 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
I need to create a flat file with columns delimited by "\002" (octal 2)
I tried using the simple echo.
name="Adam Smith"
age=40
address="1 main st"
city="New York"
echo ${name}"\002"${age}"\002"${address}"\002"${city} > mytmp
but it creates a delimiter with different octal... (4 Replies)
Hi All,
I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations:
1. I am restrained to 2 input files only.
2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)