Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(h) Enter a Unix command to verify that this file has exactly four lines. Your c

ID: 3751175 • Letter: #

Question

(h) Enter a Unix command to verify that this file has exactly four lines. Your command should print a single integer (to the monitor) that is the number of lines in this file followed by a space character and then the file name. (i) Enter a Unix command to print the number of words in this file. Your command should print a single integer (to the monitor) that is the number of words in this file followed by a space character and then the file name ) Enter a Unix command to print only the first two lines of this file to the monitor (k) Run the above command again, but this time redirect the output and save it in a file named info2.

Explanation / Answer

h) wc -l info.txt

Explanation: The standard way is with wc, which takes arguments to specify what it should count (bytes, chars, words, etc.); -l is for lines:

i) wc -w info.txt

Explanation: The standard way is with wc, which takes arguments to specify what it should count (bytes, chars, words, etc.); -l is for lines:

j)

k)

sed -n 1,2p info.txt > info2.txt