harumaki.net

インフラ屋の覚書や、ラーメン食べある記とか。

bash command GNU/Linux メモ

メモ:lsコマンドでタイムスタンプの表記を変える

投稿日:2007年5月10日

Last Updated on 2014年10月10日 by かんりにん

lsコマンドにてタイムスタンプの表記を変える場合は、オプション”-l”との併用で”–time-style”をつけ
各種表記やdateコマンド同様のフォーマットを指定しての表記が可能。
シェルスクリプトとかでタイムスタンプを条件式に入れたい時などに、ちょこっと便利。

1)manページからの抜粋

--time-style=STYLE
with -l, show times using style STYLE: full-iso, long-iso, iso, locale, +FORMAT. FORMAT is interpreted like ‘date’; if FORMAT is FOR-
MAT1<newline>FORMAT2, 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

2)書式のオプションいろいろ

1. +FORMAT

dateコマンドと同じフォーマットで指定。

$ ls -l --time-style=+"%Y-%m-%d %H:%M:%S"
total 4
-rwxr-xr-x 1 user user 58 2007-05-09 19:47:43 test.txt

2. iso

$ ls -l --time-style=iso
total 4
-rwxr-xr-x 1 user user 58 05-09 19:47 test.txt

3. long-iso

$ ls -l --time-style=long-iso
total 4
-rwxr-xr-x 1 user user 58 2007-05-09 19:47 test.txt

4. full-iso

$ ls -l --time-style=full-iso
total 4
-rwxr-xr-x 1 user user 58 2007-05-09 19:47:43.000000000 +0900 test.txt

と、こんな感じで。

-bash, command, GNU/Linux, メモ
-,

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


関連記事

no image

opensshにてfingerprint確認を省略する設定

[pukiwiki] // tag // ssh openssh // fingerprint // Are you sure you want to continue connecting // k …

nagios core​/3.監視対象設定

※編集中 関連記事: nagios core​/1.インストール nagiosgraph​/メモ:nagiosグラフで出力されるレポートについて nagios​/plugin​/SNMP​/mem監視 …

no image

[メモ]panasonic スイッチのファームウェアアップデート(Switch-M24eG PN28240)

パナソニック電工(現在はパナソニックESネットワークス)のSwitch M24eGのファームウェアのアップデートメモ。 syslog周りの設定をしておこうとしたところ、メーカーの紹介ページでは実装され …

nagios NRPEインストール

  [pukiwiki] *NRPEインストールログ [#udb00d6c] 作業日:2010-11-22 -参考ページ お世話になっています!! –NRPE (Nagios Remote …

nagiosgraph​/2.詳細設定

  [pukiwiki] nagiosgraphの詳細設定。一部編集中です(スイマセン) 不明点は都度INSTALLドキュメントを参照すること。 http://nagiosgraph.svn.sour …

宅麺