BITS(1) | User Commands | BITS(1) |
NAME
bits - convert bit masks from/to various formats
SYNOPSIS
bits [-h] [-V] [-w <NUM>] [<MODE>] [<MASK_OR_LIST>...]
DESCRIPTION
The bits utility converts bit masks into various formats. It supports combining multiple masks together using bitwise operations.
POSITIONAL ARGUMENTS
<MASK_OR_LIST>
If no argument is specified, the sets of bits will be read from standard input; one group per line.
Consecutive ids can be compressed as ranges (e.g. 5,6,7,8,9,10 → 5-10).
Optionally, if an argument starts with a comma, it will be parsed as a single hexadecimal mask split in 32bit groups (e.g. ,00014000,00000000,00020000 → 17,78,80).
By default all groups will be OR’ed together. If a group has one of the following prefixes, it will be combined with the resulting mask using a different binary operation:
&<MASK_OR_LIST>
^<MASK_OR_LIST>
~<MASK_OR_LIST>
OPTIONS
-w <NUM>, --width <NUM>
-h, --help
-V, --version
CONVERSION MODE
One of the following conversion modes can be specified. If not specified, it defaults to -m, --mask.
-m, --mask
-g, --grouped-mask
-b, --binary
-l, --list
EXAMPLES
~$ bits --mask 4,5-8 16,30 0x400101f0 ~$ bits --list 0xeec2 1,6,7,9-11,13-15 ~$ bits --binary 4,5-8 16,30 0b100_0000_0000_0001_0000_0001_1111_0000 ~$ bits --list ,00300000,03000000,30000003 0,1,28,29,56,57,84,85 ~$ bits --list 1,2,3,4 ~3-10 1,2 ~$ bits --list 1,2,3,4 ^3-10 1,2,5-10 ~$ bits --grouped-mask 2,22,74,79 8400,00000000,00400004 ~$ bits --width 64 --list 2,22,74,79 2,22
AUTHORS
Robin Jarry.
REPORTING BUGS
For bug reports, use the issue tracker https://github.com/util-linux/util-linux/issues.
AVAILABILITY
The bits command is part of the util-linux package which can be downloaded from Linux Kernel Archive https://www.kernel.org/pub/linux/utils/util-linux/.
2025-03-29 | util-linux 2.41 |