1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

md: improve the display for dd, expr and stat

This commit is contained in:
Sylvestre Ledru 2023-03-04 13:27:20 +01:00
parent 422a27d375
commit c68324a58c
3 changed files with 162 additions and 172 deletions

View file

@ -11,119 +11,116 @@ Copy, and optionally convert, a file system resource
## After Help ## After Help
OPERANDS: ### Operands
bs=BYTES read and write up to BYTES bytes at a time (default: 512); - `Bs=BYTES` : read and write up to BYTES bytes at a time (default: 512);
overwrites ibs and obs. overwrites `ibs` and `obs`.
cbs=BYTES the 'conversion block size' in bytes. Applies to - `cbs=BYTES` : the 'conversion block size' in bytes. Applies to the
the conv=block, and conv=unblock operations. `conv=block`, and `conv=unblock` operations.
conv=CONVS a comma-separated list of conversion options or - `conv=CONVS` : a comma-separated list of conversion options or (for legacy
(for legacy reasons) file flags. reasons) file flags.
count=N stop reading input after N ibs-sized read operations rather - `count=N` : stop reading input after N ibs-sized read operations rather
than proceeding until EOF. See iflag=count_bytes if stopping than proceeding until EOF. See `iflag=count_bytes` if stopping after N bytes
after N bytes is preferred is preferred
ibs=N the size of buffer used for reads (default: 512) - `ibs=N` : the size of buffer used for reads (default: 512)
if=FILE the file used for input. When not specified, stdin is used instead - `if=FILE` : the file used for input. When not specified, stdin is used instead
iflag=FLAGS a comma-separated list of input flags which specify how the input - `iflag=FLAGS` : a comma-separated list of input flags which specify how the
source is treated. FLAGS may be any of the input-flags or input source is treated. FLAGS may be any of the input-flags or general-flags
general-flags specified below. specified below.
skip=N (or iseek=N) skip N ibs-sized records into input before beginning - `skip=N` (or `iseek=N`) : skip N ibs-sized records into input before beginning
copy/convert operations. See iflag=seek_bytes if seeking N bytes copy/convert operations. See iflag=seek_bytes if seeking N bytes is preferred.
is preferred. - `obs=N` : the size of buffer used for writes (default: 512)
obs=N the size of buffer used for writes (default: 512) - `of=FILE` : the file used for output. When not specified, stdout is used
of=FILE the file used for output. When not specified, stdout is used
instead instead
oflag=FLAGS comma separated list of output flags which specify how the output - `oflag=FLAGS` : comma separated list of output flags which specify how the
source is treated. FLAGS may be any of the output flags or output source is treated. FLAGS may be any of the output flags or general
general flags specified below flags specified below
seek=N (or oseek=N) seeks N obs-sized records into output before - `seek=N` (or `oseek=N`) : seeks N obs-sized records into output before
beginning copy/convert operations. See oflag=seek_bytes if beginning copy/convert operations. See oflag=seek_bytes if seeking N bytes is
seeking N bytes is preferred preferred
status=LEVEL controls whether volume and performance stats are written to - `status=LEVEL` : controls whether volume and performance stats are written to
stderr. stderr.
When unspecified, dd will print stats upon completion. An When unspecified, dd will print stats upon completion. An example is below.
example is below.
```plain
6+0 records in 6+0 records in
16+0 records out 16+0 records out
8192 bytes (8.2 kB, 8.0 KiB) copied, 0.00057009 s, 8192 bytes (8.2 kB, 8.0 KiB) copied, 0.00057009 s,
14.4 MB/s 14.4 MB/s
The first two lines are the 'volume' stats and the final line ```
is the 'performance' stats.
The volume stats indicate the number of complete and partial The first two lines are the 'volume' stats and the final line is the
ibs-sized reads, or obs-sized writes that took place during 'performance' stats.
the copy. The format of the volume stats is The volume stats indicate the number of complete and partial ibs-sized reads,
<complete>+<partial>. If records have been truncated (see or obs-sized writes that took place during the copy. The format of the volume
conv=block), the volume stats will contain the number of stats is `<complete>+<partial>`. If records have been truncated (see
truncated records. `conv=block`), the volume stats will contain the number of truncated records.
Possible LEVEL values are: Possible LEVEL values are:
progress: Print periodic performance stats as the copy - `progress` : Print periodic performance stats as the copy proceeds.
proceeds. - `noxfer` : Print final volume stats, but not performance stats.
noxfer: Print final volume stats, but not performance stats. - `none` : Do not print any stats.
none: Do not print any stats.
Printing performance stats is also triggered by the INFO signal Printing performance stats is also triggered by the INFO signal (where supported),
(where supported), or the USR1 signal. Setting the or the USR1 signal. Setting the POSIXLY_CORRECT environment variable to any value
POSIXLY_CORRECT environment variable to any value (including (including an empty value) will cause the USR1 signal to be ignored.
an empty value) will cause the USR1 signal to be ignored.
CONVERSION OPTIONS: ### Conversion Options
ascii convert from EBCDIC to ASCII. This is the inverse of the 'ebcdic' - `ascii` : convert from EBCDIC to ASCII. This is the inverse of the `ebcdic`
option. Implies conv=unblock. option. Implies `conv=unblock`.
ebcdic convert from ASCII to EBCDIC. This is the inverse of the 'ascii' - `ebcdic` : convert from ASCII to EBCDIC. This is the inverse of the `ascii`
option. Implies conv=block. option. Implies `conv=block`.
ibm convert from ASCII to EBCDIC, applying the conventions for '[', ']' - `ibm` : convert from ASCII to EBCDIC, applying the conventions for `[`, `]`
and '~' specified in POSIX. Implies conv=block. and `~` specified in POSIX. Implies `conv=block`.
ucase convert from lower-case to upper-case - `ucase` : convert from lower-case to upper-case.
lcase converts from upper-case to lower-case. - `lcase` : converts from upper-case to lower-case.
block for each newline less than the size indicated by cbs=BYTES, remove - `block` : for each newline less than the size indicated by cbs=BYTES, remove
the newline and pad with spaces up to cbs. Lines longer than cbs the newline and pad with spaces up to cbs. Lines longer than cbs are truncated.
are truncated. - `unblock` : for each block of input of the size indicated by cbs=BYTES, remove
unblock for each block of input of the size indicated by cbs=BYTES, remove
right-trailing spaces and replace with a newline character. right-trailing spaces and replace with a newline character.
sparse attempts to seek the output when an obs-sized block consists of only - `sparse` : attempts to seek the output when an obs-sized block consists of
zeros. only zeros.
swab swaps each adjacent pair of bytes. If an odd number of bytes is - `swab` : swaps each adjacent pair of bytes. If an odd number of bytes is
present, the final byte is omitted. present, the final byte is omitted.
sync pad each ibs-sided block with zeros. If 'block' or 'unblock' is - `sync` : pad each ibs-sided block with zeros. If `block` or `unblock` is
specified, pad with spaces instead. specified, pad with spaces instead.
excl the output file must be created. Fail if the output file is already - `excl` : the output file must be created. Fail if the output file is already
present. present.
nocreat the output file will not be created. Fail if the output file in not - `nocreat` : the output file will not be created. Fail if the output file in
already present. not already present.
notrunc the output file will not be truncated. If this option is not - `notrunc` : the output file will not be truncated. If this option is not
present, output will be truncated when opened. present, output will be truncated when opened.
noerror all read errors will be ignored. If this option is not present, dd - `noerror` : all read errors will be ignored. If this option is not present,
will only ignore Error::Interrupted. dd will only ignore Error::Interrupted.
fdatasync data will be written before finishing. - `fdatasync` : data will be written before finishing.
fsync data and metadata will be written before finishing. - `fsync` : data and metadata will be written before finishing.
INPUT FLAGS: ### Input flags
count_bytes a value to count=N will be interpreted as bytes. - `count_bytes` : a value to `count=N` will be interpreted as bytes.
skip_bytes a value to skip=N will be interpreted as bytes. - `skip_bytes` : a value to `skip=N` will be interpreted as bytes.
fullblock wait for ibs bytes from each read. zero-length reads are still - `fullblock` : wait for ibs bytes from each read. zero-length reads are still
considered EOF. considered EOF.
OUTPUT FLAGS: ### Output flags
append open file in append mode. Consider setting conv=notrunc as well. - `append` : open file in append mode. Consider setting conv=notrunc as well.
seek_bytes a value to seek=N will be interpreted as bytes. - `seek_bytes` : a value to seek=N will be interpreted as bytes.
GENERAL FLAGS: ### General Flags
direct use direct I/O for data. - `Direct` : use direct I/O for data.
directory fail unless the given input (if used as an iflag) or output (if used - `directory` : fail unless the given input (if used as an iflag) or
as an oflag) is a directory. output (if used as an oflag) is a directory.
dsync use synchronized I/O for data. - `dsync` : use synchronized I/O for data.
sync use synchronized I/O for data and metadata. - `sync` : use synchronized I/O for data and metadata.
nonblock use non-blocking I/O. - `nonblock` : use non-blocking I/O.
noatime do not update access time. - `noatime` : do not update access time.
nocache request that OS drop cache. - `nocache` : request that OS drop cache.
noctty do not assign a controlling tty. - `noctty` : do not assign a controlling tty.
nofollow do not follow system links. - `nofollow` : do not follow system links.

View file

@ -14,34 +14,27 @@ separates increasing precedence groups.
`EXPRESSION` may be: `EXPRESSION` may be:
ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2 - `ARG1 | ARG2`: `ARG1` if it is neither null nor 0, otherwise `ARG2`
- `ARG1 & ARG2`: `ARG1` if neither argument is null or 0, otherwise 0
ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0 - `ARG1 < ARG2`: `ARG1` is less than `ARG2`
- `ARG1 <= ARG2`: `ARG1` is less than or equal to `ARG2`
ARG1 < ARG2 ARG1 is less than ARG2 - `ARG1 = ARG2`: `ARG1` is equal to `ARG2`
ARG1 <= ARG2 ARG1 is less than or equal to ARG2 - `ARG1 != ARG2`: `ARG1` is unequal to `ARG2`
ARG1 = ARG2 ARG1 is equal to ARG2 - `ARG1 >= ARG2`: `ARG1` is greater than or equal to `ARG2`
ARG1 != ARG2 ARG1 is unequal to ARG2 - `ARG1 > ARG2`: `ARG1` is greater than `ARG2`
ARG1 >= ARG2 ARG1 is greater than or equal to ARG2 - `ARG1 + ARG2`: arithmetic sum of `ARG1` and `ARG2`
ARG1 > ARG2 ARG1 is greater than ARG2 - `ARG1 - ARG2`: arithmetic difference of `ARG1` and `ARG2`
- `ARG1 * ARG2`: arithmetic product of `ARG1` and `ARG2`
ARG1 + ARG2 arithmetic sum of ARG1 and ARG2 - `ARG1 / ARG2`: arithmetic quotient of `ARG1` divided by `ARG2`
ARG1 - ARG2 arithmetic difference of ARG1 and ARG2 - `ARG1 % ARG2`: arithmetic remainder of `ARG1` divided by `ARG2`
- `STRING : REGEXP`: anchored pattern match of `REGEXP` in `STRING`
ARG1 * ARG2 arithmetic product of ARG1 and ARG2 - `match STRING REGEXP`: same as `STRING : REGEXP`
ARG1 / ARG2 arithmetic quotient of ARG1 divided by ARG2 - `substr STRING POS LENGTH`: substring of `STRING`, `POS` counted from 1
ARG1 % ARG2 arithmetic remainder of ARG1 divided by ARG2 - `index STRING CHARS`: index in `STRING` where any `CHARS` is found, or 0
- `length STRING`: length of `STRING`
STRING : REGEXP anchored pattern match of REGEXP in STRING - `+ TOKEN`: interpret `TOKEN` as a string, even if it is a keyword like `match`
or an operator like `/`
match STRING REGEXP same as STRING : REGEXP - `( EXPRESSION )`: value of `EXPRESSION`
substr STRING POS LENGTH substring of STRING, POS counted from 1
index STRING CHARS index in STRING where any CHARS is found, or 0
length STRING length of STRING
+ TOKEN interpret TOKEN as a string, even if it is a
keyword like 'match' or an operator like '/'
( EXPRESSION ) value of EXPRESSION
Beware that many operators need to be escaped or quoted for shells. Beware that many operators need to be escaped or quoted for shells.
Comparisons are arithmetic if both ARGs are numbers, else lexicographical. Comparisons are arithmetic if both ARGs are numbers, else lexicographical.

View file

@ -8,53 +8,53 @@ Display file or file system status.
## Long Usage ## Long Usage
The valid format sequences for files (without `--file-system`): Valid format sequences for files (without `--file-system`):
%a access rights in octal (note '#' and '0' printf flags) - `%a`: access rights in octal (note '#' and '0' printf flags)
%A access rights in human readable form - `%A`: access rights in human readable form
%b number of blocks allocated (see %B) - `%b`: number of blocks allocated (see %B)
%B the size in bytes of each block reported by %b - `%B`: the size in bytes of each block reported by %b
%C SELinux security context string - `%C`: SELinux security context string
%d device number in decimal - `%d`: device number in decimal
%D device number in hex - `%D`: device number in hex
%f raw mode in hex - `%f`: raw mode in hex
%F file type - `%F`: file type
%g group ID of owner - `%g`: group ID of owner
%G group name of owner - `%G`: group name of owner
%h number of hard links - `%h`: number of hard links
%i inode number - `%i`: inode number
%m mount point - `%m`: mount point
%n file name - `%n`: file name
%N quoted file name with dereference if symbolic link - `%N`: quoted file name with dereference if symbolic link
%o optimal I/O transfer size hint - `%o`: optimal I/O transfer size hint
%s total size, in bytes - `%s`: total size, in bytes
%t major device type in hex, for character/block device special files - `%t`: major device type in hex, for character/block device special files
%T minor device type in hex, for character/block device special files - `%T`: minor device type in hex, for character/block device special files
%u user ID of owner - `%u`: user ID of owner
%U user name of owner - `%U`: user name of owner
%w time of file birth, human-readable; - if unknown - `%w`: time of file birth, human-readable; - if unknown
%W time of file birth, seconds since Epoch; 0 if unknown - `%W`: time of file birth, seconds since Epoch; 0 if unknown
%x time of last access, human-readable - `%x`: time of last access, human-readable
%X time of last access, seconds since Epoch - `%X`: time of last access, seconds since Epoch
%y time of last data modification, human-readable - `%y`: time of last data modification, human-readable
%Y time of last data modification, seconds since Epoch - `%Y`: time of last data modification, seconds since Epoch
%z time of last status change, human-readable - `%z`: time of last status change, human-readable
%Z time of last status change, seconds since Epoch - `%Z`: time of last status change, seconds since Epoch
Valid format sequences for file systems: Valid format sequences for file systems:
%a free blocks available to non-superuser - `%a`: free blocks available to non-superuser
%b total data blocks in file system - `%b`: total data blocks in file system
%c total file nodes in file system - `%c`: total file nodes in file system
%d free file nodes in file system - `%d`: free file nodes in file system
%f free blocks in file system - `%f`: free blocks in file system
%i file system ID in hex - `%i`: file system ID in hex
%l maximum length of filenames - `%l`: maximum length of filenames
%n file name - `%n`: file name
%s block size (for faster transfers) - `%s`: block size (for faster transfers)
%S fundamental block size (for block counts) - `%S`: fundamental block size (for block counts)
%t file system type in hex - `%t`: file system type in hex
%T file system type in human readable form - `%T`: file system type in human readable form
NOTE: your shell may have its own version of stat, which usually supersedes NOTE: your shell may have its own version of stat, which usually supersedes
the version described here. Please refer to your shell's documentation the version described here. Please refer to your shell's documentation