Recall & Review
beginner
What does the
-f file test operator check in a bash script?The
-f operator checks if a given path is a regular file (not a directory or special file).Click to reveal answer
beginner
How do you test if a directory exists using bash file test operators?
Use the
-d operator to check if a directory exists at the given path.Click to reveal answer
intermediate
What is the difference between
-e and -f operators?-e checks if a file or directory exists (any type), while -f checks specifically for a regular file.Click to reveal answer
beginner
Which file test operator checks if a file is readable?
The
-r operator checks if the current user has read permission on the file.Click to reveal answer
beginner
Explain what
-w and -x operators check in bash.-w checks if the file is writable, and -x checks if the file is executable by the current user.Click to reveal answer
Which operator would you use to check if a file exists regardless of type?
✗ Incorrect
The
-e operator checks if any file or directory exists at the path.What does the
-d operator test for?✗ Incorrect
-d tests if the path is a directory.If you want to check if a file can be executed, which operator do you use?
✗ Incorrect
-x checks if the file is executable.Which operator would confirm a file is writable?
✗ Incorrect
-w checks write permission on the file.What does
-f specifically check?✗ Incorrect
-f checks if the file is a regular file.Describe how you would check if a file exists and is readable in a bash script using file test operators.
Think about testing existence first, then readability.
You got /4 concepts.
Explain the difference between checking if a path is a directory versus a regular file using bash file test operators.
Directories and files behave differently in scripts.
You got /4 concepts.