Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/unix/unix_command/ls/ls.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/unix/unix_command/ls/ls.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/unix/unix_command/ls/ls.html on line 2
ls | 時間ごとにソート | UNIX | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/unix/unix_command/ls/ls.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/unix/unix_command/ls/ls.html on line 17
ls
lsコマンドはファイルの一覧を表示するコマンドです。
ただ単に

ls
と実行すると、カレントディレクトリのファイルの一覧を表示します。
また

ls ディレクトリ名
と実行すると、そのディレクトリ配下のファイル一覧を表示します。
カレントディレクトリの特定のファイルだけを表示したい場合はワイルドカードを使用します。
以下は、拡張子がtxtのファイルを表示するように実行しています。

ls *.txt
ls
ls

ls -lオプション
lsコマンドに-lオプションを指定すると、ファイルを詳細表示してくれます。
以下、実行例です。

ls -lオプション
ls -lオプション

左からファイルのパーミッション、ファイルのリンク数もしくはディレクトリ配下のファイルのリンク数、ファイルまたはディレクトリの所有者とその所有者の所属するグループ、ファイルサイズ(バイト)、ファイル更新日時、ファイル名が表示されます。

ls -aオプション
Unixでは、ドット(.)で始まるファイルは隠しファイルとして扱われます。
このファイルはlsコマンドでは表示されません。が、-aオプションを使用することで隠しファイルも含めて表示することが出来ます。
使用方法は

ls -a
と実行するだけです。

ls -Fオプション
lsコマンドで表示されたファイルがシンボリックリンクであったり実はディレクトリであったりと、普通のlsコマンドでは判断がつきません。
-Fオプションを使用すると、そのファイルが何であるかを表示してくれます。

使用方法は

ls -F
と実行するだけです。以下のようにファイルの末尾に、*や@等のマークが付加されます。

ディレクトリには /
シンボリックリンクには@
実行可能ファイルには*
普通のファイルには何もなし

となります。他にもいくつかマークがあります。

ls -Fオプション
ls -Fオプション

ディレクトリにあるファイル数を調べる
lsコマンドとwcコマンドを使ってディレクトリにあるファイル数を調べることが出来ます。
ls | wc -l
で、ファイル数を調べることが出来ます。

時間ごとにソートする
時間(タイムスタンプ)ごとにソートして表示したい場合は、-tオプションを使用します。
これで昇順に表示されます。

ls -lat
逆に時間の降順にソートしたい場合、rtオプションを使用します。

ls -lart

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/unix/unix_command/ls/ls.html on line 164

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/unix/unix_command/ls/ls.html on line 164

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/unix/unix_command/ls/ls.html on line 173

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/unix/unix_command/ls/ls.html on line 173