Linuxコマンド  >  L  >  ls
ls
2012/10/18

ls コマンドの使用例です。 ls コマンドはディレクトリの内容を表示するコマンドです。

◆環境
OS Linux 2.6.18-53.el5

ls のバージョンの確認

lsのバージョンを確認します。

$ ls --version
ls (GNU coreutils) 5.97
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License .
There is NO WARRANTY, to the extent permitted by law.

Written by Richard Stallman and David MacKenzie.

ディレクトリの内容を表示

$ ls
makefile  test  test.c  test.o

ファイルの詳細情報を表示

-lオプションを付けると以下の情報が表示されます。

  • ファイルのモード
  • リンクの数
  • 所有者
  • グループ名
  • (バイト単位の)サイズ
  • タイムスタンプ(デフォルトは最終修正時刻)
  • 名前
$ ls -l
合計 20
-rw-r--r-- 1 ymlib.com 804  207  7月  3  2009 makefile
-rwxr-xr-x 1 ymlib.com 804 7712 11月  5  2009 test
-rw-r--r-- 1 ymlib.com 804  727 11月  5  2009 test.c
-rw-r--r-- 1 ymlib.com 804 2080 11月  5  2009 test.o

完全な時刻を表示

--full-timeオプションを指定します。

$ ls --full-time
合計 20
-rw-r--r-- 1 ymlib.com 804  207 2009-07-03 17:25:58.000000000 +0900 mak
efile
-rwxr-xr-x 1 ymlib.com 804 7712 2009-11-05 11:35:04.000000000 +0900 tes
t
-rw-r--r-- 1 ymlib.com 804  727 2009-11-05 11:32:02.000000000 +0900 tes
t.c
-rw-r--r-- 1 ymlib.com 804 2080 2009-11-05 11:35:04.000000000 +0900 tes
t.o

状態変更時刻を表示

-cと-lオプションをあわせて指定します。

$ ls -cl
合計 20
-rw-r--r-- 1 ymlib.com 804  207 11月  5  2009 makefile
-rwxr-xr-x 1 ymlib.com 804 7712 11月  5  2009 test
-rw-r--r-- 1 ymlib.com 804  727 11月  5  2009 test.c
-rw-r--r-- 1 ymlib.com 804 2080 11月  5  2009 test.o

最終アクセス時刻を表示

-uと-lオプションをあわせて指定します。

$ ls -ul
合計 20
-rw-r--r-- 1 ymlib.com 804  207 10月 15 15:40 makefile
-rwxr-xr-x 1 ymlib.com 804 7712 10月 15 15:40 test
-rw-r--r-- 1 ymlib.com 804  727 10月 15 15:40 test.c
-rw-r--r-- 1 ymlib.com 804 2080 10月 15 15:40 test.o

任意の文字から始まるファイルを表示する

t から始まるファイルだけを表示してみます。 引数にt*を指定します。

$ ls -t*
test  test.c  test.o

▲ PageTop  ■ Home


Copyright (C) 2012 ymlib.com