Friday, September 13, 2013

Usefull Unix ls commands


Don’t you hate when you want to see the specific time on a file and ls -l gives you this on older files:

oracle@ > ls -ltr
total 2328
-rw-r--r-- 1 oracle oinstall  22413 Jun  5 10:59 ashrpt_1_0605_0900.txt
-rw-r--r-- 1 oracle oinstall    247 Jun  5 11:31 afiedt.buf
-rw-r--r-- 1 oracle oinstall 255934 Jun  5 11:33 awrrpt_1_11390_11391.txt
-rw-r--r-- 1 oracle oinstall  14594 Jun  5 11:33 addmrpt_1_11390_11391.txt

Fortunately, ls gives us some options:

oracle@  > ls -ltr --full-time
total 2328

-rw-r--r-- 1 oracle oinstall  22413 2013-06-05 10:59:55.000000000 -0400 ashrpt_1_0605_0900.txt
-rw-r--r-- 1 oracle oinstall    247 2013-06-05 11:31:29.000000000 -0400 afiedt.buf
-rw-r--r-- 1 oracle oinstall 255934 2013-06-05 11:33:09.000000000 -0400 awrrpt_1_11390_11391.txt
-rw-r--r-- 1 oracle oinstall  14594 2013-06-05 11:33:25.000000000 -0400 addmrpt_1_11390_11391.txt




or this using the same format options the date command uses. In this case year-month-day.24 hour:minute

oracle@ > ls -ltr --time-style=+%F.%R
total 2328

-rw-r--r-- 1 oracle oinstall  22413 2013-06-05.10:59 ashrpt_1_0605_0900.txt
-rw-r--r-- 1 oracle oinstall    247 2013-06-05.11:31 afiedt.buf
-rw-r--r-- 1 oracle oinstall 255934 2013-06-05.11:33 awrrpt_1_11390_11391.txt
-rw-r--r-- 1 oracle oinstall  14594 2013-06-05.11:33 addmrpt_1_11390_11391.txt


Got to love it.