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

This is a linux assignment.The format will look like this: ls –l | egrep ‘ regex

ID: 3603204 • Letter: T

Question

This is a linux assignment.The format will look like this: ls –l | egrep ‘regex’ where regex is a regular expression. It’s important to place regular expressions for grep (or egrep) inside quotes so that the shell does not try to expand it. Change back to /etc. For each of the following, your answer is the proper instruction that you came up with to solve the problem (don’t reply with the files that were listed). Just the command you used please

a.Type ls –l. The 6th column contains the month of creation (abbreviated) and the 8th column contains the time of the file’s creation if created this year, or the year if created in a previous year. The command ls –l | egrep ‘Jan’ will display all files created in any January. Write an instruction that will list the files that were created in 2011.

b.Come up with the proper instruction to find all items that are symbolic links. Recall that symbolic links are listed with an ‘l’ (lower case L) as the first character and with -> in the file name. Come up with 2 different regexes for this.

c.List all items that are not normal files. Normal files all start with a -, so find all files that do not.

d.List all files with size > 9999 (size is at least a 5-digit number).

e.List all files whose names have three consecutive r’s, s’s or t’s (in any order/combination like rss, tts, str).

f.List all files whose name contains two a’s separated by either 1 or 2 letters (e.g., java-6-sun or aliases).

Explanation / Answer

a)

ls -l | egrep "Jans+[0-9]+s+2011"

regular excpression say Jan followed by space then followed by any number of digits (we need 1 or 2 only) then space and then 2011

b)

ls -l | egrep "^l.*->"

start with l and have -> in the line

c)

ls -l | egrep "^-"

all files starting with -

all non regular file (directory symlink etc)

ls -l | egrep -v "^-"

d)

using ls

ls -l | egrep "[0-9]{5}s...[0-9]{0,1}s"

using find

find . -maxdepth 1 -type f -size +9999c -exec ls -l {} ;

e)

ls -l | egrep "[rts]{3}"

f)

ls -l | egrep "a.{1,2}a"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote