ls -l이 숫자 크기 필드를 수천 단위로 출력하도록 할 수 있습니까? 그렇다면 어떻게 해야 할까요?
예를 들어:
$ ls -l
-rw-rw---- 1 dahl dahl 43,210,052 2012-01-01 21:52 test.py
(치수에 쉼표가 있음을 참고하세요).
아마도 내가 사용하고 있는 로케일(en_US.utf8)에서 LC_NUMERIC 설정을 수정하면 되지 않을까요?
저는 쿠분투 12.04 LTS를 사용하고 있습니다.
답변1
앞에 '가 있는 블록 크기 사양은 출력 크기가 천 단위 구분 기호와 함께 표시되도록 합니다. (블록 크기를 지정하는 것만으로는 충분하지 않습니다.)
그러니 원하는 것에 따라 시도해 볼 수 있습니다.
BLOCK_SIZE="'1" ls -l
BLOCK_SIZE="'1kB" ls -l
또는
ls -l --block-size="'1"
ls -l --block-size="'1kB"
이것을 사용하여 영구적으로 만들 수 있습니다
export BLOCK_SIZE="'1"
export BLOCK_SIZE="'1kB"
또는
alias ls="ls --block-size=\"'1\""
alias ls="ls --block-size=\"'1kB\""
답변2
ast-open 사용 ( ls
ast-open 의 일부로 내장된 ls
if 내장 함수 도 사용 ksh93
):
$ ls -rSZ "%(mode)s %3(nlink)u %-8(uid)s %-8(gid)s %8(device:case::%'(size)u:*:%(device)s)s %(mtime)s %(name)s%(linkop:case:?*: %(linkop)s %(linkpath)s)s"
[...]
-rwxrwxr-x 1 chazelas chazelas 2,701,278 Apr 27 2016 nmake
-rwxrwxr-x 2 chazelas chazelas 4,515,954 Apr 27 2016 ksh
-rwxrwxr-x 2 chazelas chazelas 4,515,954 Apr 27 2016 bash
-rwxrwxr-x 1 chazelas chazelas 4,542,177 Apr 27 2016 shcomp
-rwxrwxr-x 1 chazelas chazelas 6,830,418 Apr 27 2016 tksh
이는 일반적으로 사용되는 형식이지만 천 단위 구분 기호를 표시 하도록 변경 ls -l
되었습니다 .%(size)u
%'(size)u
더 명확하게:
LONG_FORMAT_WITH_THOUSAND_SEP="\
%(mode)s \
%3(nlink)u \
%-8(uid)s \
%-8(gid)s \
%8(device:case::%'(size)u:*:%(device)s)s \
%(mtime)s \
%(name)s\
%(linkop:case:?*: %(linkop)s %(linkpath)s)s"
ls -rSZ "$LONG_FORMAT_WITH_THOUSAND_SEP"
답변3
매뉴얼 페이지에서
--block-size=SIZE
scale sizes by SIZE before printing them. E.g., `--block-size=M'
prints sizes in units of 1,048,576 bytes. See SIZE format below.
_이것은 ls의 매뉴얼 페이지입니다. man이 가장 친한 친구라는 것을 기억하세요. 터미널에 "man man"을 입력하여 그것이 얼마나 유용한지 확인하세요.
ls
List information about files.
Syntax
ls [Options]... [File]...
Key
Sort entries alphabetically if none of -cftuSUX nor --sort.
-a, --all Do not hide entries starting with .
-A, --almost-all Do not list implied . and ..
-b, --escape Print octal escapes for nongraphic characters
--block-size=SIZE Use SIZE-byte blocks
-B, --ignore-backups Do not list implied entries ending with ~
-c Sort by change time; with -l: show ctime
-C List entries by columns
--color[=WHEN] Control whether color is used to distinguish file
types. WHEN may be `never', `always', or `auto'
-d, --directory List directory entries instead of contents
-D, --dired Generate output designed for Emacs' dired mode
-f Do not sort, enable -aU, disable -lst
-F, --classify Append indicator (one of */=@|) to entries
--format=WORD Across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
--full-time List both full date and full time
-g (ignored)
-G, --no-group Inhibit display of group information
-h, --human-readable Print sizes in human readable format (e.g., 1K 234M 2G)
-H, --si Likewise, but use powers of 1000 not 1024
--indicator-style=WORD Append indicator with style WORD to entry names:
none (default), classify (-F), file-type (-p)
-i, --inode Print index number of each file
-I, --ignore=PATTERN Do not list implied entries matching shell PATTERN
-k, --kilobytes Like --block-size=1024
-l Use a long listing format
-L, --dereference List entries pointed to by symbolic links
-m Fill width with a comma separated list of entries
-n, --numeric-uid-gid List numeric UIDs and GIDs instead of names
-N, --literal Print raw entry names (don't treat e.g. control
characters specially)
-o Use long listing format without group info
-p, --file-type Append indicator (one of /=@|) to entries
-q, --hide-control-chars Print ? instead of non graphic characters
--show-control-chars Show non graphic characters as-is (default)
-Q, --quote-name Enclose entry names in double quotes
--quoting-style=WORD Use quoting style WORD for entry names:
literal, shell, shell-always, c, escape
-r, --reverse Reverse order while sorting
-R, --recursive List subdirectories recursively
-s, --size Print size of each file, in blocks
-S Sort by file size
--sort=WORD time -t, version -v, status -c
size -S, extension -X, none -U
atime -u, access -u, use -u
--time=WORD Show time as WORD instead of modification time:
atime, access, use, ctime or status;
also use this as a sort key if --sort=time
-t sort by modification time
-T, --tabsize=COLS assume tab stops at each COLS instead of 8
-u sort by last access time; with -l: show atime
-U do not sort; list entries in directory order
-v sort by version
-w, --width=COLS assume screen width instead of current value
-x list entries by lines instead of by columns
-X sort alphabetically by entry extension
-1 list one file per line
--help display help and exit
--version output version information and exit