dポイントプレゼントキャンペーン実施中!

Linuxで「ls -lk」を実行しても、ファイルサイズがバイト表示になってしまいます。
すべてのファイルをキロバイトで表示する方法はないでしょうか。
※-hはファイルサイズによって表示が異なるので使用不可

OS:centos7.6

lsマニュアル表示
-k, --kibibytes
default to 1024-byte blocks for disk usage

A 回答 (2件)

man ls をよく読むと



> SEE ALSO
> Full documentation at: <http://www.gnu.org/software/coreutils/ls>
> or available locally via: info '(coreutils) ls invocation

とあると思います。
# 「man を読むときは SEE ALSO を読むこと」と先輩から教わりました。

それに従って見てみると

http://www.gnu.org/software/coreutils/manual/htm …
> ‘-k’
> ‘--kibibytes’
> The -k or --kibibytes option affects the per-directory block count written by the -l and similar options, and the size written by the -s or --size option.
> It does not affect the file size written by -l.

とあり、
ディレクトリ毎のブロック数表示(-sオプション等で出力される)に適用されるもので、
-l オプションのファイルサイズには適用されない、と書いてあります。


http://www.gnu.org/software/coreutils/manual/htm …
> ‘-l’
> ‘--format=long’
> ‘--format=verbose’
> Normally the size is printed as a byte count without punctuation, but this can be overridden (see Block size).
> For example, -h prints an abbreviated, human-readable count, and ‘--block-size="'1"’ prints a byte count with the thousands separator of the current locale.

こちらには、 ファイルサイズ表示を変更する方法が書いてあります。
    • good
    • 0
この回答へのお礼

回答いただきありがとうございます

お礼日時:2019/06/07 00:28

man ls で確認すると,一番簡単なのは


ls -ls
で各行の左端に KB で表示されるようです。あるいは
ls --block-size=1K -l
かな? ただし,これは cygwin での確認でした。
    • good
    • 0
この回答へのお礼

遅くなりましたが、回答いただきありがとうございます。

お礼日時:2019/06/07 00:28

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!