Linux Quiz 8 Regular Expressions vs Wildcards "Need help to see if I got them correct or not" Write the command line to

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Linux Quiz 8 Regular Expressions vs Wildcards "Need help to see if I got them correct or not" Write the command line to

Post by answerhappygod »

Linux Quiz 8 Regular Expressions vs Wildcards "Need help
to see if I got them correct or not"
Write the command line to do each of the following. Use only the
commands "ls" or "grep" or "sed"! This is not a test of commands,
but of regular expressions and wildcards. For some questions there
is no command line that will work (using just these commands and no
pipe). For those questions, just write "impossible" or "no". DO NOT
LEAVE SUCH QUESTIONS BLANK!
NOTE1: For the "sed" command, DO NOT USE
"sed -i"!
NOTE2: For the impossible commands, using
a pipe is possible. I will accept those answers if they are done
correctly.
NOTE3: Do not try to use the "find"
command, unless you are an expert! One problem with it is that it
searches subdirectories, so can get many more answers than
desired.
NOTE4: You should quote the patterns in
"grep", else some characters may be treated as wildcards and have
file names substituted.
xgh
1. Find all the files in your current
directory with an “x” as the second character in the name.
My Answer: grep
2. Find all the lines in file “testing”
that contain an “x” as the second character in the line.
My Answer: grep
3. Find all the lines in file “testing”
that contain a word with “x” as the second character.
My Answer: grep
4. Find all the files in your current
directory whose name starts with “g” and ends with “h”, but can
only have “x”s between them.
My Answer: sed
5. Find all the lines in file “testing”
that start with “g” and end with “h”, but can only have “x”s
between the first "g" and last "h".
My Answer: ls
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply