The tail command is used to output the last part of a file, and by default it shows the last 10 lines. To limit the output to exactly one line (the last line), the -n option must be specified with a value of 1, as in tail -n 1 foo.txt. Using tail alone without -n 1 would show up to 10 lines instead of just the last one, and head displays lines from the beginning of the file rather than the end. The last command is unrelated to file content — it is used to show a listing of last logged-in users.
Community Discussion