Complete the command to display the first 5 lines of a file named 'log.txt'.
head -n [1] log.txt-n 10 shows 10 lines instead of 5.-n option.The head command with -n 5 shows the first 5 lines of the file.
Complete the command to display the last 3 lines of a file named 'data.csv'.
tail -n [1] data.csv-n 5 shows 5 lines instead of 3.head with tail.The tail command with -n 3 shows the last 3 lines of the file.
Fix the error in the command to show the first 8 lines of 'report.txt'.
head [1] 8 report.txt
-c which shows bytes instead of lines.-f which follows the file continuously.The correct option to specify number of lines in head is -n. The option -c is for bytes, -f is for following the file.
Fill both blanks to create a command that shows lines 5 to 10 of 'file.txt' using head and tail.
head -n [1] file.txt | tail -n [2]
head -n 6 instead of 10.tail -n 5 instead of 6.First, head -n 10 gets the first 10 lines. Then, tail -n 6 gets the last 6 lines of those 10, which are lines 5 to 10.
Fill all three blanks to create a command that shows lines containing 'error' (case-insensitive) from the last 4 lines of the first 20 lines of 'access.log'.
head -n [1] access.log | tail -n [2] | grep -i [3]
This command first gets the first 20 lines with head -n 20, then the last 4 lines of those with tail -n 4, and finally filters lines containing 'error' (case-insensitive) with grep -i "error".