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

[メモ]sudo su -設定

たまにド忘れするのでメモ。 サーバー構築時にパス無しでsudo su -したいとき用に。 1)wheelグループへ追加 # vi /etc/group または # vigr wheelグループへsud …

no image

net-snmp v3設定

[pukiwiki] 自分用メモです。 v3に対応していないアプライアンスもあるので、使い道は限定されますが・・・ *なんとなくOverview snmp v1、v2でのコミュニティによる認証をしてい …

no image

openssh6.1 ソースからのインストール

元々CentOSに入っているopensshから、最新版の機能を試したいので、現在借りているさくらのVPSにソースからインストールをしてみることに。 make installするタイミングで一旦RPM版 …

nagios​/plugin​/SNMP​/インストール(コンパイル版)

  [pukiwiki] **nagiosプラグインの環境セットアップ(コンパイル版) [#oac4bee6] リモートホストへsnmpで値を取得する”check_snmp_*&#8221 …

nagios​/plugin​/SNMP​/ロードアベレージ監視

  [pukiwiki] *ロードアベレージ監視[check_snmp_load.pl] [#v02685d2] **スクリプト [#g9e2c6a2] check_snmp_load.pl 使用例: …

宅麺