Skip to main content

Removing duplicates with awk

To remove duplicates in linux you can use awk command as follows:

 awk -F- '!seen[$1]++' file.txt > output.txt

where:

-F is paraeter to deternime separator used to define columns and in ths case the dash 8-) is the sparator used

'!seen[$1]++' is the expression used for the line in order to be printed

> is the instruction to send command output o a file

Comments

Popular posts from this blog

Register new WCS store view by using database

To register a new view by using SQL queries: insert into acaction (acaction_id, action) values ((select counter from keys where tablename='acaction'), 'NewView');  insert into acactactgp (ACACTGRP_ID,ACACTION_ID) values  ((SELECT ACACTGRP_ID FROM ACACTGRP WHERE GROUPNAME = 'AllSiteUsersViews'  and member_id in (select orgentity_id from orgentity where orgentityname='Root Organization')  ),  (select acaction_id from acaction where action='NewView'));  UPDATE KEYS SET COUNTER = COUNTER+1 WHERE TABLENAME = 'acaction'; commit