Which grep command will print only the lines that do not end with a / in the file foo?
Suggested Answer: C
Get Premium LFCS Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
24 comments · newest first
KI
Kiera
10 months ago
C makes sense, but I’m still a bit confused.
DA
Dalene
10 months ago
I thought it would be A at first!
YU
Yuonne
11 months ago
Wait, why would B be an option?
CH
Chu
11 months ago
Definitely agree, C is correct.
KA
Katy
11 months ago
C is the right answer!
CH
Cheryl
12 months ago
I’m confused about the difference between the options with $ and #. Does $ mean end of line?
MI
Michel
12 months ago
I feel like I saw a similar question where we had to filter out certain endings, and I think it was using -v.
GR
Gracia
1 year ago
I remember practicing with grep, but I’m not sure if it’s -v or just the regular grep.
JE
Jestine
1 year ago
I think the command we want needs to exclude lines ending with a slash, so maybe it's the one with -v?
LO
Loreen
1 year ago
Yeah, I agree with Leila. The -v option in grep will invert the match, so it will print the lines that don't match the pattern.
LE
Leila
1 year ago
Okay, I think I've got it. The question is asking for lines that don't end with a slash, so the correct answer must be option C: grep -v '/$' foo.
SH
Sharen
1 year ago
Hmm, I'm a bit confused. Is it looking for lines that end with a slash or don't end with a slash? The wording is a bit tricky.
LA
Lashawn
1 year ago
This looks like a straightforward grep question. I think the key is to find the right pattern to match lines that don't end with a slash.
AM
Amber
1 year ago
Haha, I bet the person who wrote this question is a real 'slash' enthusiast. Option C is the winner!
BO
Bobbie
1 year ago
B is clearly wrong, the hash symbol isn't the right thing to look for here.
SH
Shawnta
1 year ago
I agree with Joni, option C makes more sense because it uses the -v flag to invert the match.
LE
Lemuel
1 year ago
Option C looks right, I don't want to end up with lines that have a forward slash at the end.
LY
Lynelle
10 months ago
Agreed! No trailing slashes for me either!
DO
Dorothy
10 months ago
I was confused at first, but C makes sense.
TH
Theola
11 months ago
Definitely! It filters out those pesky slashes.
SH
Sharika
11 months ago
I think C is the best choice too!
JO
Joni
1 year ago
But the question specifically asks for lines that do not end with a /, so option D is incorrect.
EM
Emilio
1 year ago
I disagree, I believe the answer is D) grep -v '/#' foo.
JO
Joni
1 year ago
I think the answer is C) grep -v '/$' foo.