Lab09

.docx

School

Langara College *

*We aren’t endorsed by this school

Course

1280

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

2

Uploaded by raman16894

Report
Lab 09 – Search & Pattern Matching using grep Objective To understand the behaviour of grep on a CSV file. Resources Needed PC with Ubuntu 20.04 LTS or higher installed, OR Ubuntu 20.04 LTS or higher installed as a VirtualBox or VMware virtual machine, OR A running instance of Ubuntu 20.04 LTS or higher on AWS About the Lab Most Linux administration tasks involve manipulating text files (configuration files, log files, text-based content, etc.). Linux shell commands are designed to work with text streams and are very convenient in dealing with text-based data. In this lab, you will be practicing how to extract information using grep from the data file tuition.csv . The Task For all questions, you are expected to write a one-line bash command (but you can use semi-colon ‘;’ to string commands together). Commands allowed: tail, grep, cut, sort, wc, | . 1. Show the count of only the data lines in the file (skip the header lines) grep -c "^AY" tuition.csv 2. Show the count of all the colleges in the file. grep -c "College" tuition.csv 3. Show the count of all the institutes in the file. grep -c "Institute" tuition.csv 4. Show the count of all the teaching-intensive universities in the file. grep -c "Teaching-Intensive University" tuition.csv 5. Show the count of all the research-intensive universities in the file. grep -c "Research-Intensive University" tuition.csv 6. Output all unique institution names, regardless of College or Institute or University. tail -n +7 tuition.csv | cut -d',' -f4 | sort -u 7. Find all data lines that contain Langara grep "Langara" tuition.csv 8. Display the names of colleges in the Mainland/Southwest region? Page 1 of 2
grep "College" tuition.csv | grep "Mainland/Southwest" | cut -d',' -f4 | sort -u 9. For the 2019/20 year, show only school names and tuition amounts , sorted in ascending order of school names grep "AY 2019/20" tuition.csv | cut -d',' -f4- | sort 10. Use grep find all institutions that have the tuition between 20,000 to 30,000 grep -E '"\$(2[0-9],\d{3}|30,000)"' tuition.csv Submission: What to hand in Upload the edited document Lab09.docx (which includes all your answers) to Brightspace. Submission: When to hand in Before midnight (11:59 PM) tomorrow. Page 2 of 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help