How to know the inode of a file of directory:
$ls -i <- displays the innode of the file& directory in current directory
Ex:
$ ls -i
320785 a 320800 abc 320786 b 320787 c
The numbers represents the inode
How to list files sorted with modification time:
$ls -lt <- displays with time sorted manner with latest first
Ex:
$ ls -lt
total 4
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:54 c.odt
drwxr-xr-x 2 hanu hanu 4096 Aug 26 11:53 empty_dir
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:53 a.txt
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:53 b.png
Note: if you want to reverse the output of ls add option -r
Ex:
$ ls -ltr
total 4
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:53 b.png
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:53 a.txt
drwxr-xr-x 2 hanu hanu 4096 Aug 26 11:53 empty_dir
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:54 c.odt
A Blog for technical Linux, shell, php, mysql, python, OpenSource | Career | Books | Movies
Customized search within this blog
Showing posts with label ls. Show all posts
Showing posts with label ls. Show all posts
Thursday, August 25, 2011
Wednesday, December 29, 2010
Using "ls" and "find" command how to display only directories..?
Following commands list only directories in the current directory.
1. #ls -l | grep ^d
2. #ls -d */
3. #find -type d
Ex: #find /tmp -type d <-- This command shows all the directories with in the /tmp directory.
Want only files to be listed.. use 1. #ls -l | grep -v ^d
1. #ls -l | grep ^d
2. #ls -d */
3. #find
Ex: #find /tmp -type d <-- This command shows all the directories with in the /tmp directory.
2. #find -type f
Ex: #find /tmp -type f <-- This command shows all regular files with in the /tmp directory.
Ex: #find /tmp -type f <-- This command shows all regular files with in the /tmp directory.
Subscribe to:
Posts (Atom)