Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following directory listing: [you blue logs]$ 1s dnf.err mail.com.l

ID: 3837471 • Letter: C

Question

Consider the following directory listing: [you blue logs]$ 1s dnf.err mail.com.log-20170116 messages.rpm.log-20170116 dnf. lib. log mail.err secure.ssh.log-20170116 dnf.lib.log-20170112 mail.log spooler.err Which command will return a list of the files that have a. err extension, except spooler.err? The directory ~ jmora/midterm/maze contains a maze where each directory represents a door to a room. On each room you will find a chest and doors to other rooms (subdirectories). A "chest" is a regular file, which can be either empty, or have directions that will lead you to the treasure (the chest under maze is one of these), or in case of the chest with the treasure, it will have the word "ruby" (there is only one of this kind) Your mission is to find the chest with the treasure.

Explanation / Answer

As the question contains multiple parts of questions I am providing the answer for the first part only.

In LINUX there are multiple commands to list out all files. the command 'ls' is mainly used to list all files in a directory, In the same way the command 'grep' is also used to print lines matching a pattern.

Below are the commands to list out the files that have .err extension except the file spooler.err

ls | grep '.err$' | -not spooler.err

In the above command, ls lists out all files and grep command matches the pattern so it gives all files having .err extension, but the requirement is to not list the spooler.err so we can use 'not' to exclude spooler.err file.


ls -l *.err | grep -v spooler.err

The use of grep -v command is to nvert the sense of matching, that is to select non-matching lines. So the file spooler.err file will be excluded in the list.


find . -maxdepth 1 -mindepth 1 -name *.err -a -not -name spooler.err

The above command lists out all files in the current directory or below, with an exact depth of 1 (so really only in the current directory and not the name of the current directory itself) with name matching the pattern .err except spooler.err