Advertisement
dtung

dup.lua

May 5th, 2020
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.27 KB | None | 0 0
  1. local lines = {}
  2.  
  3. -- read the stdin and count the duplicate lines
  4. for line in io.lines() do
  5.     lines[line] =  lines[line] and lines[line]+1 or 1
  6. end
  7.  
  8. -- print out lines occur more than once
  9. for k, v in pairs(lines) do
  10.     if v > 1 then io.write(k, "\n") end
  11. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement