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

wordpressメモ、サイトのURLを変更する際のテーブル操作

職場でイントラ用に利用しているwordpressサイトを別サーバーに引っ越した際、サイトURLのメンテを忘れてしまい、後から手動で直すことに。 直す必要があるのは”WordPress アド …

no image

RedHatEnterprise3.0​/bonding(結合インターフェース)

[pukiwiki] #topicpath #contents *bonding(結合インターフェース) 結合インターフェースbondingの設定方法。 **参考URL お世話になっております。 ht …

no image

[メモ]cdコマンドで、ひとつ前のディレクトリに戻る場合[bash]

シェルでの作業中に、ふたつのディレクトリを行ったり来たり、ということが多いとき cdとかのオプションで指定できないかな?とmanを探っていたら、ふつーにあった(汗 $ cd – (オプション&quot …

no image

AWstatsのインストール(RPM版)

[pukiwiki] アクセスログ解析ツールawstatのインストールのメモ。 Software Design2006年1月号を参照。 今回はローカル上で運用しているバーチャルホストのログを解析。 ※ …

no image

JDK+Tocmat+Tomcat-connectorのインストール

[pukiwiki] 【今回の環境】 OS CentOS4.* FrontEnd Httpd-2.0.52(RPM) JDK jdk-1.5.0_07-fcs Tomcat apache-tomcat …