Duplicate Line Finder

Problem

Have you ever duplicated a cron entry, or just wanted to find duplicate lines in a file.



Solution

Here is a simple one liner, which shows all lines which occur more than once in a file or standard output.



Example



sort cronfile.223 | uniq -c | awk ' $1 != 1 '

So to check that cron directly – just do this:


crontab -l | uniq -c | awk ' $1 != 1 '



Reference

[tags]UNIX, awk, script, uniq, Unix Coding School[/tags]



Leave a Reply

Your email address will not be published. Required fields are marked *