Title: Quiz 8 - Filters
Course: CIS 121: Linux/UNIX I: Fundamentals ~ For IGNITE Review

Q: Display all lines from file1 that have xyz in them.
A: grep "xyz" file 1 / grep xyz file 1 / grep 'xyz' file 1

Q: Display all lines from file1 with all letters upper case.
A: cat file1 | tr '[a-z]' '[A-Z]' / cat file1 | tr "[a-z]" "[A-Z]"

Q: Display the output of the who command showing only the uname at the beginning of the line. If you care, unames are not more than 8 characters in length and the separator is a blank. If you don't care, that still is true.
A: who | cut -c-8 / who | cut -d ' ' -f1 / who | cut -c 1-8 / who |awk '{print $1}'

Q: Merge files f1 f2 and f3 so that all line 1's are merged, all line 2's are merged, etc.
A: paste f1 f2 f3

Q: Display only lines 5-9 of file 1
A: sed -n '5,9p' file1 / head -9 file1 | tail +5 / cat file1 | head -9 | tail + 5 / tail +5 file1 | head -5 / head -9 file1| tail -5 / cat file1 | head -9 | tail -5 / cat file1 | sed -n '5,9p' / sed -n 5,9p file1 / sed -n "5,9p" file1 / cat file1 | tail +5 | head -5 / head -9 file1 | tail -5 | more / more file1 | tail +5 | head -5

Q: Find the lines in "sports" that occur more than once.
A: sort sports | uniq -d / cat sports | sort | uniq -d

Q: Display file1 with every pattern 'cat' changed to 'dog'.
A: sed 's/cat/dog/g' file1 / cat file1 | sed 's/cat/dog/g' / sed 's/cat/dog/g' < file1 / sed s/cat/dog/g file1 / sed "s/cat/dog/g" file1 / more file1 | sed 's/cat/dog/g'

Q: Display the line in file1 that occurs the most times.
A: sort file1 | uniq -c | sort -nr | head -1 / sort file1 | uniq -c | sort -n | tail -1 / cat file1 | sort | uniq -c | sort -n | tail -1 / sort file1 | uniq -c | sort -rn | head -1 / cat file1 | sort | uniq -c | sort -rn | head -1 / cat file1 | sort | uniq -c | sort -nr | head -1 / more file1 |sort | uniq -c | sort -rn | head -1 / cat file1 | sort | uniq -c | sort -n -r | head -1 / sort file1 | uniq -c | sort | tail -1

Q: List the names of all files in or under your home directory that were created or modified in the last two weeks.
A: find ~ -mtime -14 / find ~/ -mtime -14 / find $HOME -mtime -14 / find ~/. -mtime -14 -print / find ~ -mtime -14 -print / find ~ -type -f -mtime -14

Q: Write a command to find the number of times the pattern "xyzzy" occurs in file13 regardless of the case of the characters.
A: grep -ic "xyzzy" file13 / grep -ci xyzzy file13 / grep -i xyzzy file13|wc -l / grep '[xX][yY][zZ][zZ][yY]' file13 | wc -l

Q: Who was the primary person responsible for the development of the Linux operating system?
A: Linus Torvalds / Linus B. Torvalds
If wrong: Linus Torvalds was the primary person responsible for the development of the Linux operating system.