LolzPB

cat

May 21st, 2020
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. args = {...}
  2.  
  3. if #args < 1 then --Controllo se sono stati inseriti tutti i parametri
  4. print("Uso: cat <file>")
  5. return
  6. end
  7.  
  8. cdir = "/"
  9.  
  10. --Controllo se il file richiesto esiste
  11. if fs.exists(shell.dir().."/"..args[1]) then
  12. cdir = shell.dir().."/"..args[1]
  13. elseif fs.exists(args[1]) then
  14. cdir = args[1]
  15. end
  16.  
  17. --Leggo e printo il contenuto del file richiesto
  18. file = fs.open(cdir, "r")
  19. print(file.readAll())
  20. file.close()
Add Comment
Please, Sign In to add comment