Find and count duplicate lines in files

Search and count text files for duplicate or multiple content

When editing text or configuration files in the Linux shell, there can often be the requirement that identical entries in the files occur only once, so that to check how many times a line was duplicated, especially in files with a larger number of lines, this does not have to be done manually, help provide the use of the filters sort and uniq in the Linux bash.

This command counts duplicate lines and sorts the output in the bash.

$ sort FILE | uniq --count

  Replace the FILE placeholder with the real file name.

Only duplicate lines should be shown.

$ sort FILE | uniq --count --repeated

Nothing is displayed if there are no duplicate lines in the file.

Windows Terminal Warning Insert Multiple Lines

Windows Terminal Warning: You are about to paste text that contains multiple lines

When pasting multiple lines from the clipboard in Windows Terminal, the warning message appears:

  You are about to paste text that contains multiple lines. If you paste this text into your shell, it may result in the unexpected execution of commands. Do you wish to continue?

Windows Terminal Warning, You are about to paste text that contains multible lines.

When working in the shell, the security warning can be useful, but when editing it is more of a handicap, but there is the suitable option “multiLinePasteWarning” which can be set from true to false.

"$schema": "",
"defaultProfile": "PowerShell",
"alwaysShowTabs": true,
"copyFormatting": "none",
"copyOnSelect": true,,
"multiLinePasteWarning": false,

After the Windows Terminal setting with Ctrl+, and open JSON file, under the section $schema the option “multiLinePasteWarning”: false has been inserted, the warning for multi-line pasting no longer appears.