ls -l コマンドに年が無い。。
ls -l でファイルのタイムスタンプを確認。
$ ls -l test.rb -rw-r--r--+ 1 staff 1349 5 6 17:40 test.rb
何年のファイルかぱっと分からない。最近のディレクトリならかまわないけれど、何年も使っているLinuxのシステムだとファイルの月日だけは不十分だ。
--full-time オプションを使う。
そんなときは --full-time オプションを使えば便利。
$ ls -l --full-time test.rb -rw-r--r--+ 1 staff 1349 2014-05-06 17:40:23.000000000 +0900 test.rb
これで、年月日を確認できるようになる。
full-time 見にくいよね?
詳細すぎて冗長だわ。
そんなときは date コマンドスタイル。で "2014-05-06 17:40:23"形式
$ ls -l --time-style=+%Y-%m-%d\ %H:%M:%S test.rb -rw-r--r--+ 1 staff 1349 2014-05-06 17:40:23 test.rb
date 今度の書式で、日付が西暦から表示されて便利になる。2014-05-06 17:40:23 となる。
それでも、+%Y-%m-%d\ %H:%M:%Sは覚えやすいけど、打ちにくい。そこで long-isoをつかう。
alias lly="ls -l --time-style=long-iso"
これで少し楽になると思います。
詳しくは man page ( gnu ls の場合)
--full-time like -l --time-style=full-iso --time-style=STYLE with -l, show times using style STYLE: full-iso, long-iso, iso, locale, or +FORMAT; FORMAT is interpreted like in 'date'; if FORMAT is FORMAT1<newline>FORMAT2, then FORMAT1 applies to non-recent files and FORMAT2 to recent files; if STYLE is prefixed with 'posix-', STYLE takes effect only outside the POSIX locale
man を読むと・・・ --time-style
ls -l --time-style=XXX
このXXXの部分に、いくつも使えることが分かる。
--time-styleの実行例
--time-style=iso
$ ls -l --time-style=iso test.rb -rw-r--r--+ 1 staff 1349 05-06 17:40 test.rb
full-iso
$ ls -l --time-style=full-iso test.rb -rw-r--r--+ 1 staff 1349 2014-05-06 17:40:23.000000000 +0900 test.rb
long-iso
$ ls -l --time-style=long-iso test.rb -rw-r--r--+ 1 staff 1349 2014-05-06 17:40 test.rb
locale
$ ls -l --time-style=locale test.rb -rw-r--r--+ 1 staff 1349 5 6 17:40 test.rb
+%Y-%m-%d
$ ls -l --time-style=+%Y-%m-%d test.rb -rw-r--r--+ 1 staff 1349 2014-05-06 test.rb
date スタイル使えるの便利だね!