Mwnci file() Function

Syntax

file(filename, [extra])

Description

The file() function returns the last modification time of the file filename in epoch seconds (seconds since midnight, January 1, 1970). If the file does not exist, the file() function returns the NULL string.

The user does not need permission to read the file but does require search permission on each directory in the path name leading to filename. If the user does not have such permission, the file() function fails and returns the NULL string.

When the extra parameter is specified, the file() function returns a more detailed string of information.

When the optional extra parameter used, the additional information is given:

modtime atime ctime mode size numlinks type fileuid filegid
  • modtime is the last modification date expressed in epoch seconds
  • atime is the last access time expressed in epoch seconds
  • ctime is the last change status express in epoch seconds
  • mode is the permissions expressed as an octal integer
  • size is the length of the file expressed as the number of characters
  • numlinks is the number of links to the file
  • type is a string indicating the file type:
    • FILE – ordinary data file
    • DIR – directory
    • CHR – character special file
    • BLOCK – block special file
    • FIFO – pipe
    • LINK – symbolic link
    • SOCKET – Unix domain socket
    • UNKNOWN – unknown file type
  • fileuid is the user id of the file owner
  • filegid is the group id associated with the file

Example

filename="/etc/passwd"
a=file(filename)
if (a) {
    println("Enhanced Information: \n",file(filename,1))
} else {
    println("File does not exist")
}


1665739665 1671171901 1665739665 0644 2779 1 FILE 0 0