Difference between revisions of "Ls"

From DevOps Notebook
(Created page with "Linux sort files by size with ls <pre> # ls -S -l # ls -l -S | sort -k 5 -n # sort top 5 largest files in reverse order # ls -l -S -h # sort by size in human readable format...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Linux sort files by size with ls
+
=== Linux sort files by size with ls ===
 
<pre>
 
<pre>
 
# ls -S -l
 
# ls -S -l
Line 5: Line 5:
 
# ls -l -S -h # sort by size in human readable format
 
# ls -l -S -h # sort by size in human readable format
 
# ls -Slhr | grep -v '^d' # exclude directories from sort by size with ls
 
# ls -Slhr | grep -v '^d' # exclude directories from sort by size with ls
 +
</pre>
 +
 +
=== View  access timestamp (atime), the modified timestamp (mtime), and the changed timestamp (ctime) with ls ===
 +
<pre>
 +
# ls -l myfile.c # shows mtime
 +
# ls -lu myfile.c # shows atime
 +
# ls -lc myfile.c # shows ctime
 
</pre>
 
</pre>

Latest revision as of 12:57, 2 November 2020

Linux sort files by size with ls

# ls -S -l
# ls -l -S | sort -k 5 -n  # sort top 5 largest files in reverse order
# ls -l -S -h # sort by size in human readable format
# ls -Slhr | grep -v '^d' # exclude directories from sort by size with ls

View access timestamp (atime), the modified timestamp (mtime), and the changed timestamp (ctime) with ls

# ls -l myfile.c # shows mtime
# ls -lu myfile.c # shows atime
# ls -lc myfile.c # shows ctime