A
A
Asparagales2019-01-02 07:50:10
linux
Asparagales, 2019-01-02 07:50:10

Why is the uniq command not working properly?

There is a catalog. It contains other subdirectories, which in turn contains more subdirectories and files. I need to find duplicate names of files and directories in it. I tried the following command:
ls -1R /путь до основного каталога | uniq -D
No results.
Then I tried to do this:

ls -1R /путь до основного каталога > file
uniq -D file

Again there is no result, but it should be, because for the sake of experiment I copied one of the files to different subdirectories.
But if you create a file and add arbitrary text to it:
spoiler
Мой дядя самых честных правил
Когда не в шутку занемог
Когда не в шутку занемог
Он уважать себя заставил
И лучше выдумать не мог
И лучше выдумать не мог

Those expected result is.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2019-01-02
@Asparagales

Why is the uniq command not working properly?

Because it expects repeated lines to follow each other. You can insert sort before uniq into the pipeline to group the same lines.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question