From the course: CompTIA Linux+ (XK0-005) Cert Prep

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

File conditions

File conditions

- [Instructor] Using if conditionals, we can do quite a few tests on files. Let's get right into it. - e checks if the file exists. Now, in Linux everything is a file, including devices. This check doesn't discern. - f, however, checks if a file exists and is a file. - d checks if a file exists and is a directory. - c checks if a file exists and is a character device. - b checks if a file exists and is a block device. - p checks if a file exists and is a named pipe. - S checks if a file exists and is a socket. - L check if file exists and is a symbolic link. - g checks if a file exists and has the SGID bit set. - u checks if a file exists and has the SUID bit set. - r checks if a file exists and is readable by the current user. - w checks if a file exists and is writeable by the current user. - x checks if a file exists and it's executable by the current user. - s checks if a file exists and it has a size larger than…

Contents