Question

In: Computer Science

Use the find command to find all directories under /pub/cs/ whose name is cs160a. Be sure to only display the results that match, do not display any error output.

Unix/Linux

1)
Use the find command to find all directories under /pub/cs/ whose name is cs160a. Be sure to only display the results that match, do not display any error output.
Hint: use: 2>/dev/null.

2)
Create a one-line command, using he famous.dat file, to add the word " STREET" to the address, for all who live on 2nd or 3rd.
For example: '2nd' becomes "2nd STREET" and '3rd' becomes "3rd STREET".
Display only the first 9 lines.
Hint: use 2 sed statements with pipes.

3)
Display all lines in famous.dat that end in 0 or 1, and have a 1 in the 3rd from the last column.
For example lines ending in 120 and 131 would be displayed.

4)
Display all lines in famous.dat that have only 4, 5, 6, 7 and 9 in the zip code.
HINT: this is the same as NOT 0,1,2,3 or 8.

5)
Using only the grep command, search all files with names that end in either .html or .htm under the$HOME/public_html directory and display any lines that contain body tags (containing ''). No other output should be displayed even if there is no public_html directory.
Hint: use two command arguments and 2>

Solutions

Expert Solution

Answer 1
***********

as i do not have /pub/cs directory so its not showing anything

Answer 2
***********

Answer 3
***********

WITHOUT PROPER FAMOUS.DAT FILE CANT FIND THE PROPER ANSWER BUT I TRIED MY LEVEL BEST.

Answer 4
***********

egrep "[45679]{5}$" famous.dat

Answer 5
************

grep -r --include=*.{html,htm} "" $HOME/public_html 2>/dev/null


Related Solutions

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT