File Commands:
- ls ---------------------- >>> Directory Listing
- ls -ltr ---------------------- >>> Listing ascending order
- ls -lt ---------------------- >>> Listing ascending order
- ls -al ---------------------- >>> Listing with HIDDEN Files also...
ls -l file*
- -rw-r--r-- 1 haritaraka12078 haritaraka12078 0 May 31 13:54 file1
- -rw-r--r-- 1 haritaraka12078 haritaraka12078 0 May 31 13:53 file1,file2,file3
- -rw-r--r-- 1 haritaraka12078 haritaraka12078 0 May 31 13:54 file2
- -rw-r--r-- 1 haritaraka12078 haritaraka12078 0 May 31 13:54 file3
- -rw-r--r-- 1 haritaraka12078 haritaraka12078 0 May 31 13:57 file7
- -rw-r--r-- 1 haritaraka12078 haritaraka12078 57 Jun 1 05:33 file.txt
Note:
ls ltr
drwxr-xr-x 2 haritaraka12078 haritaraka12078 4096 May 30 05:13 cloudxlab_jupyter_notebooks
- drwxr-xr-x ----------- >>> Permissions
- 2 ----------- >>> replication factor
- haritaraka12078 ----------- >>> group
- haritaraka12078 ----------- >>> user
- 4096 ----------- >>> size
- May 30 05:13 ----------- >>> created time
------------>>to sort only folders in reverse order based on conversion time.
ls -lt /home/adimulamvenkat19851609 | grep ^d
------------->> files 120 days ago
find /home/adimulamvenkat19851609 -type f -mtime +120 -ls
------------->> Today files
find /home/adimulamvenkat19851609 -type f -mtime -1 -ls | wc -l
------------->> Today directories
find /home/adimulamvenkat19851609 -type d -mtime -1 -ls
--------------->> last 30 minutes
find /home/adimulamvenkat19851609 -mmin -30 -ls
--------------->> Delete last 30 minutes files
find /home/adimulamvenkat19851609 -mmin -30 -ls -delete
--------------->>Top 5 files
ls -1t | head -5
--------------->> Last 5 files
ls -lht | tail -5
-l
outputs in a list format
-h
makes output human readable (i.e. file sizes appear in kb, mb, etc.)
-t
sorts output by placing most recently modified file first
head -6
will show 5 files because ls
prints the block size in the first line of output.