\'egrep\' runs grep in a different mode. Same as grep -E. Special characters don
ID: 3723019 • Letter: #
Question
'egrep' runs grep in a different mode. Same as grep -E. Special characters don't have to be marked with So + is written+..is written (...), etc. In extended regexps, + is a literal + Questions: Give the command(s) to get the matching output for each question. You will need to try different commands to match the output image. Use the /etc/services file for each question. 1. Use 'grep' to find the information about the HTTP protocol in the file /etc/services. Print all lines which begin with http or https. 80/tcp 80/udp 443/tcp 443/udp 8080/tcp 888/udp # WorldWideWeb HTTP # HyperText Transfer Protocol # http protocol over TLS/SSL WWw ttps ps http-alt ttp-alt webcache # WIN caching service Usually this file contains some comments, starting with the the-v option to ignore lines starting with and look at the rest of the file in less. "The less' command allows you to look at the data page by page. Typeto quit 'less' 2. symbol. Use 'grep, withExplanation / Answer
1. grep http /etc/services
Explanation : As mentioned in the question the above query will extract the lines resulting in contents only with http / https.
2. grep http /etc/services | grep -v '#' | less
Explanation : From the result that we got in previous lines we are presented only with lines that dont have a comment in them and they are presented in a special page on bash where you will have to enter q to exit.
3. grep http /etc/services } grep ^$ | more
Explanation: similar to previous command but here we are removing blank lines the regex ^$ indicates that the content of line will have nothing since '^' means start and '$' means end thus nothing in between them indicate empty line.
4. grep "bin/bash" /etc/passwd | awk -F: '{ print $1}'
Explanation: after applying the command to copy the passwd file to tmp when you apply this command before pipeline would result in cotents of file wherein the path contains "bin/bash" this will return us the paths of the users using bash as their shell while the awk print $1 indicates printing of first word of each lne in the contents.
5. grep "bin/bash" /etc/passwd | awk -F: '{print $1," ",$3}'
Explanation:Similar to previous command here the print statement will print first and third word since they contain user name and uid respectively
6. awk -F: '{print $1," ",$2}'
explanation : ' for your last question apply the above with pipeline to the query you will get the final result since the previous command is not available i couldn't get you the complete command.
note : If you found the answer useful please give a thumbsup (could really help :P) and if you have any queries please comment
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.