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'm piping a list of words around that looks something like this
do
done
every
done
do
very-do
done-every
done
every
do
I want to remove the duplicates.
Both sort -u and uniq are supposed to do this, but on this column of words they can neither sort according to alpha, string value, or properly count.
Uniq -c gives me the number 1 next to each of these words even though they are clearly identical. I've done a ton of sed and tr to remove any leading spaces and it is really only these words and the invisible newline.
I have been using sed and tr to try and remove leading and trailing spaces and I have looked at all of the options for sort and uniq trying to find other keys to sort on that might illuminate what is not visible, like by translating all words into numbers, and the effect is the same. And I have read a lot of sort uniq howtos and what is suggested there is not working on this. I'm really puzzled why this doesn't work and I am honestly perplexed by the issue as well as the whole 'hidden characters' thing. I want to understand it better.
These words are in a variable in a chain of pipes with sed removing leading spaces, tr replacing newlines with spaces, and I tried to sort | uniq -u and visa versa numerous ways before posting.
cat -vte shows a $ at the end of every line but nothing that should make the duplicate lines unique from. right? if I remove the $ then it puts them all back into a flat string row. every other time ive used sort and uniq its been on a column with newlines.
Why does sort not put these in alphabetical order?
When the most basic thing doesnt work that is the world telling you that you dont know something that you should know. So what is it that I'm missing?
cat -vte is useful and cool thank you for teaching me this.
(btw I'd like to use the code tags but when I click on the buttons in my browser, nothing happens, no tooltips either so I'm not sure those are the right buttons even, javascript allowed, blocker off also, FF)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.