ls command

LINUX-Frequently used commands

ls command Display a list of files in a directory
Syntax
ls   [Option]  [path]
Displays the files and directories stored in the directory.
The ls command has a number of options which allow you to display information about files and directories in a variety of formats.
Use this if you want to see what files and directories are in the directory you are accessing (the current directory).
Frequently used options
-l     View file details
-t     Sort files by timestamp (ascending)
-lt    Sort and display file details by timestamp
-lrt   Display file details in reverse order by timestamp
Example: View file details.
$ ls -l ← Add "-l (lowercase el)" to the right of "ls" as an option
total 16

-rw-rw-r-- 1koro koro 0 Jan 27 02:48 data.dat
-rw-rw-r-- 1koro koro 0 Jan 27 02:48 out.txt
-rw-rw-r-- 1koro koro 0 Jan 27 02:48 test.dat
-rw-rw-r-- 1koro koro 0 Jan 27 02:49 tmp.dat
Example: Replace multiple consecutive blank lines with a single blank line
$  cat -s temp1.txt   ←  Run it with the option "-s".
A.    abc
B.   def
C.    ghi
  A blank line becomes  one line.
D.
Copied title and URL