... 192.168.1.8 - - [01/Dec/2021:00:04:30 -0500] "GET /stuff.html HTTP/1.1" ... ⋮

The lines are in chronological order with timestamps, but they aren’t in alphabetical or numeric order, so the sort -r command isn’t helpful. The tac command can reverse these lines without needing to consider the timestamps.

The paste Command

The paste command combines files side by side in columns separated by a single tab character. It’s a partner to the cut command, which extracts columns from a tab-separated file:

$ cat title-words1
EFFICIENT
AT
COMMAND
$ cat title-words2
linux
the
line
$ paste title-words1 title-words2
EFFICIENT	linux
AT	the
COMMAND line
$ paste title-words1 title-words2 | cut -f2        cut & paste are complementary
linux
the
line

Change the separator to another character, such as a comma, with the option -d (meaning “delimiter”):

$ paste -d, title-words1 title-words2
EFFICIENT,linux
AT,the
COMMAND,line

Transpose the output, producing pasted rows instead of pasted columns, with the -s option:

$ paste -d, -s title-words1 title-words2
EFFICIENT,AT,COMMAND
linux,the,line

paste also interleaves data from two or more files if you change the separator to a newline character (\n):

$ paste -d "\n" title-words1 title-words2
EFFICIENT
linux
AT
the
COMMAND
line

The diff Command

diff compares two files line by line and prints a terse report about their differences:

$ cat file1
Linux is all about efficiency.
I hope you will enjoy this book.
$ cat file2 MacOS is all about efficiency. I hope you will ...

Get Efficient Linux at the Command Line now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.