Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a case where if I do sort -u on some foreign characters it removes both lines, instead of just one. (only happens for a few usernames which is odd)
I figure it's a bug with sort (GNU coreutils) 5.97 but I won't be able to get the sys-admins to patch the system.
So is there a way of removing duplicate lines from a file with another tool?
There are occasions where sort is inappropriate, so @colucix has a useful answer. Of course, not all awk behaves as expected - I have a SunOS awk doing mighty strange things at present.
There are occasions where sort is inappropriate, so @colucix has a useful answer. Of course, not all awk behaves as expected - I have a SunOS awk doing mighty strange things at present.
Yes, other users reported that this simple syntax doesn't work on SunOS awk. I cannot explain what is the reason, since awk on SunOS has the ! and ++ operators, it has the same concept of true and false and referencing a non-existent array element creates that element and returns the null string (false). I don't see any other rule in action here, that might eventually be specific to GNU awk. Someone reported that awk on SunOS is buggy, but I cannot verify it. Anyway, just out of curiosity, what do you get by running the suggested code on SunOS?
Anyway, just out of curiosity, what do you get by running the suggested code on SunOS?
Nothing.
As it happened I was in the mood to try a few things before I saw these responses. The ++ post operator works, the not (!) doesn't - if expanded to full "if (_[$0]++ != 0) <blah> ..." it works as expected.
I also wanted to replicate the (single) data in each line - simple. "awk '{print $0,$0}' file"
I wish ...
Testing with strings of "..." and "\t" strategically placed seemed to indicate the first field was always dropped - unless it was the only field. This was true using $0 or $1 or $NF in the command.
And of course sed wasn't smart enough to allow me to do anything useful either.
I could get *really* attached to the GNU extensions ...
Last edited by syg00; 10-23-2012 at 05:14 AM.
Reason: s/%NF/$NF/
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.