exam questions

Exam LX0-103 All Questions

View all questions & answers for the LX0-103 exam

Exam LX0-103 topic 3 question 28 discussion

Actual exam question from CompTIA's LX0-103
Question #: 28
Topic #: 3
[All LX0-103 Questions]

Which grep command will print only the lines that do not end with a / in the file foo?

  • A. grep '/$' foo
  • B. grep '/#' foo
  • C. grep -v '/$' foo
  • D. grep -v '/#' foo
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
linux_admin
2 years, 2 months ago
The command grep -v '/$' foo will print only the lines that do not end with a / in the file foo.
upvoted 1 times
linux_admin
2 years, 2 months ago
Here's a breakdown of what each part of the command does: grep is a command-line tool used to search for lines in files that match a specific pattern. -v is an option for grep that tells it to invert the search and display only the lines that do not match the pattern. '/$' is a regular expression pattern that matches a forward slash (/) at the end of a line. The backslash () is used to escape the forward slash so that it is treated as a literal character. foo is the name of the file to search in. So, the overall effect of the command is to search for lines in the file "foo" that do not end with a forward slash (/), and display those lines in the terminal window. This command can be useful for finding lines that do not represent directories, since directories in Unix-based systems are typically represented with names that end in a forward slash.
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago