ldiff.lua 651 B

12345678910111213141516171819202122232425262728293031
  1. --[[ vim: sw=4 ts=4
  2. эта программа выводит все ссылки из файла links.txt, соответствующие
  3. которым файлы не скачаны
  4. применение:
  5. $ ./ldiff links.txt | wget2 -ci-
  6. ]]--
  7. local args = {...}
  8. if not args[1] then
  9. print("specify filename")
  10. os.exit(1)
  11. end
  12. local file = io.open(args[1], "r")
  13. if not file then
  14. print("file does not exists")
  15. os.exit(2)
  16. end
  17. for line in file:lines("l") do
  18. local pos = #line - line:reverse():find('/') + 2
  19. local target = io.open(line:sub(pos), 'r')
  20. if not target then
  21. print(line)
  22. end
  23. end
  24. file:close()