Pregunta de entrevista de Google

Describe file types in Linux Program to write tail in python

Respuesta de la entrevista

Anónimo

27 jun 2022

File types in linux: 1. Regular 2. Directory 3. Symbolic links 4. Sockets 5. Named pipes 6. Block devices 7. Character devices Program to write tail in Python: - System calls used: open(), lseek(), read(). - Each iteration should increase the number of bytes read by a fixed amount relative to the end of the file. - Use lseek to move the file position at the start of each iteration. - Read in the data starting from the new file position to the end. - Determine the number of lines read in the current iteration. - If greater than the requested lines then break out of iteration and return the requested number of lines.