ls -r command in Linux

ls -r option lists all files and directories in the current directory in reverse order.

Syntax

$ ls -r [options] [file|dir]

Examples

Before using the ls -r option, let’s look at the default of the ls command.

In the following example, we use the ls -r option to list all files and directories in the current directory in reverse order.

➜  ~ ls -r

In the above example, we use the ls -r option, but this is not easy to read.

In the following example, we use the ls -rl option to list all files and directories in the current directory in a long list in reverse order.

➜  ~ ls -rl

For better reading, we can add the – t option to sort by time based on the above options. Long listing format sorted by date / time in reverse order:

➜  ~ ls -rlt

Add a Comment

Your email address will not be published.