COMPUTER SCIENCE AND ENGINEERING
UNIX
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
print the last line of a file
|
sed ‘$p’ file
|
|
sed ‘&p’ file
|
|
sed ‘!p’ file
|
|
sed ‘np’ file
|
Explanation:
Detailed explanation-1: -1p will print the first line and $p will print the last line.
Detailed explanation-2: -To look at the last few lines of a file, use the tail command. tail works the same way as head: type tail and the filename to see the last 10 lines of that file, or type tail-number filename to see the last number lines of the file.
Detailed explanation-3: -Linux Tail Command Syntax Tail is a command which prints the last few number of lines (10 lines by default) of a certain file, then terminates. Example 1: By default “tail” prints the last 10 lines of a file, then exits. as you can see, this prints the last 10 lines of /var/log/messages.
There is 1 question to complete.