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

I need help with this! Please post the command need it Open a bash shell window

ID: 3744088 • Letter: I

Question

I need help with this! Please post the command need it Open a bash shell window and Change directory to /etc/ 1. Find commands with patterns List all files/directories in the /etc/ directory that start with "p" or "q". List all files/directories in the /etc/ directory that start with "p" or "q" and must have a second letter as "p". List all files/directories in the /etc/ directory that must start the line with "se" and have the optional third letter of "r" List all files/directories in the /etc/ directory that use non-alphanumeric characters in their names List all files/directories in the /etc/ directory that use the word "yum" in their names. List all files/directories in the /etc/ directory that use digits in the name. Modify the solution of (f) to show those files and directories that have digits and end in "d". List all files/directories in the /etc/ directory that have the text strings(within the files/directories) "cron" OR "yum" a. b. c. d. e. f. g. h.

Explanation / Answer

ANS:

PFB the answers

Open a bash shell window and Change directory to /etc/

1. Find commands with patterns

a. List all files/directories in the /etc/ directory that start with “p” or “q”.

ls -rlth | awk '{print $9}' | egrep "^p|^q”

It is self explanatory, I’m taking the 9th column through awk and then using grep.

b. List all files/directories in the /etc/ directory that start with “p” or “q” and must have a second letter as “p”.

ls -rlth | awk '{print $9}' | egrep "^pp|^q”

c. List all files/directories in the /etc/ directory that must start the line with “se” and have the optional third letter of “r”.

ls -rlth /etc | awk '{print $9}' | egrep "^se|^ser”

d. List all files/directories in the /etc/ directory that use non-alphanumeric characters.

find . -type f | grep -i '[^a-z0-9./_-]'

It is a regex after the find command ignoring the case with -i option

e. List all files/directories in the /etc/ directory that use the word “yum” and do it with word boundaries.

grep -rl “yum” /etc/*

I’m assuming the question is yum to find in files and in respective directories -l is to list the files and -r recursive searching

f. List all files/directories in the /etc/ directory that use digits in the name.

find . -type f | grep -i '[0-9]'

g. Modify the solution of 7 to show those files and directories that have digits and end in “d”.

find . -type f | grep '[0-9]' | grep “d$"

Again self explanatory, We are searching for digits then pipe to the last letter d with $ expression.

PLEASE RATE