ubuntu file info command 1

ubuntu file info command

stat file_name

Here is what the above code is Doing:
1. We’re importing the os module, which contains functions for interacting with the operating system.
2. We’re importing the sys module, which contains functions for interacting with the Python interpreter.
3. We’re assigning the name sys.argv to the variable script, which means “the name of the current script.”
4. We’re assigning the second item in the sys.argv list to the variable filename, which means “the name of the file we’re getting stats for.”
5. We’re printing the value of the filename variable, which should be the name of the file we’re getting stats for.
6. We’re printing the value of the os.stat(filename).st_size variable, which should be the size of the file in bytes.

Similar Posts