The following exercise from part A to part D should be completed using Unix comm
ID: 3793401 • Letter: T
Question
The following exercise from part A to part D should be completed using Unix commands such as (grep, sed, and regular expressions)
Part A: Devise a sequence to display a count of lines containing strings containing <BR /> in all .html files in the current directory. <BR /> is case-insensitive. It can be upper or lower case.
Part B: Using sed, write a command to add the tags <HTML> to the beginning of a file and </HTML> to the end of a file.
Part C: How would you list all of the ordinary files in your directory that are not user-executable?
Part D: Devise a sequence to display the extensions of all files in the current directory along with a count of each extension.
Explanation / Answer
Part A: Devise a sequence to display a count of lines containing strings containing <BR /> in all .html files in the current directory. <BR /> is case-insensitive. It can be upper or lower case.
grep -i '<br./>' ./*.html | wc -l
Part B: Using sed, write a command to add the tags <HTML> to the beginning of a file and </HTML> to the end of a file.
sed -i '1s/^/<html> /' file_name
sed -i '$s/$/ </html>/' file_name
Part C: How would you list all of the ordinary files in your directory that are not user-executable?
ls -l | grep -e "^...-" | grep -e "^-"
Part D:.Devise a sequence to display the extensions of all files in the current directory along with a count of each extension.
ls |sed 's/.///' | sed 's/.*.//' |sort| uniq --count
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.