Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

LPI 102-500 Exam - Topic 11 Question 118 Discussion

What is the difference between the commands test -e path and test -f path?
C) Both options check the existence of the path. The -f option also confirms that it is a regular file.
A) They are equivalent options with the same behaviour.
B) The -f option tests for a regular file. The -e option tests for an empty file.
D) The -f option tests for a regular file. The -e option tests for an executable file.

LPI 102-500 Exam - Topic 11 Question 118 Discussion

Actual exam question for LPI's 102-500 exam
Question #: 118
Topic #: 11
[All 102-500 Questions]

What is the difference between the commands test -e path and test -f path?

Show Suggested Answer Hide Answer
Suggested Answer: C

The test command is used to perform checks and comparisons on files and values. The -e option tests if a given path exists, regardless of its type (file, directory, link, etc.). The -f option tests if a given path exists and is a regular file, not a directory or a special file. For example, if we have a directory named dir and a file named file, we can use the test command as follows:

test -e dir && echo ''dir exists'' dir exists test -f dir && echo ''dir is a regular file'' (no output) test -e file && echo ''file exists'' file exists test -f file && echo ''file is a regular file'' file is a regular file


https://www.computerhope.com/unix/bash/test.htm

Contribute your Thoughts:

0/2000 characters
Sharen
11 hours ago
Agreed, C makes sense. -f is more specific.
upvoted 0 times
...
Cyril
6 days ago
I think the answer is C. They both check existence.
upvoted 0 times
...
Mohammad
11 days ago
I like C. It’s clear and straightforward.
upvoted 0 times
...
Sheldon
16 days ago
No, -e just checks if the file exists, empty or not.
upvoted 0 times
...
Rosendo
21 days ago
I thought -e was for empty files. That’s what I learned.
upvoted 0 times
...
Art
26 days ago
I lean towards C too. It makes sense.
upvoted 0 times
...
Susana
1 month ago
Yes, -e checks if the path exists, but -f is for regular files.
upvoted 0 times
...
Abraham
1 month ago
I feel confused about -e. Is it really just for existence?
upvoted 0 times
...
Serita
1 month ago
I agree, but -f is more specific.
upvoted 0 times
...
Reynalda
2 months ago
I think the answer is C. They both check existence.
upvoted 0 times
...
Kerry
2 months ago
Nah, A is wrong. They definitely have different behaviors.
upvoted 0 times
...
Janella
2 months ago
Wait, so -e doesn't check if a file is empty? That's surprising!
upvoted 0 times
...
Eladia
2 months ago
Totally agree with C! They serve different purposes.
upvoted 0 times
...
Erick
2 months ago
I thought -e was for empty files? That's not right?
upvoted 0 times
...
Ashton
2 months ago
C is correct! -f checks for regular files, -e just checks existence.
upvoted 0 times
...
Twila
3 months ago
I thought -e was for any file type, but I might be mixing it up with something else.
upvoted 0 times
...
Maryann
4 months ago
I feel like both options check for existence, but I can't recall if -f confirms it's a regular file or not.
upvoted 0 times
...
Felton
4 months ago
I remember practicing a question where -f was specifically for regular files, while -e was more general.
upvoted 0 times
...
Aliza
5 months ago
I think the -e option just checks if the file exists, but I'm not sure what -f does exactly.
upvoted 0 times
...

Save Cancel