'\" t .\" Title: bits .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.26 .\" Date: 2026-04-01 .\" Manual: User Commands .\" Source: util-linux 2.42 .\" Language: English .\" .TH "BITS" "1" "2026-04-01" "util\-linux 2.42" "User Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" bits \- convert bit masks or lists from/to various formats .SH "SYNOPSIS" .sp \fBbits\fP [\fB\-h\fP] [\fB\-V\fP] [\fB\-w\fP \fInumber\fP] [\fImode\fP] [\fImask\fP|\fIlist\fP].\|.\|. .SH "DESCRIPTION" .sp The \fBbits\fP utility converts between bit masks and bit lists. It supports combining multiple masks or lists using bitwise operations. .SH "POSITIONAL ARGUMENTS" .sp \fImask\fP .RS 4 A set of bits specified as a hexadecimal mask value (for example: \fB0xeec2\fP). .RE .sp \fIlist\fP .RS 4 A set of bits specified as a comma\-separated list of bit IDs (for example: \fB1,5,29,32\fP). .RE .sp If no argument is specified, the sets of bits will be read from standard input, one group per line. .sp Consecutive IDs can be compressed as ranges (for example: \fB5,6,7,8,9,10\fP \(-> \fB5\-10\fP). .sp Optionally, if an argument starts with a comma, it will be parsed as a single hexadecimal mask split in 32\-bit groups (for example: \fB,00014000,00000000,00020000\fP \(-> \fB17,78,80\fP). .sp By default, all groups will be OR\(cqed together. If a group has one of the prefixes \fB&\fP, \fB^\fP, or \fB~\fP, it will be combined with the resulting mask using a different binary operation: .sp \fB&\fP\fImask\fP|\fB&\fP\fIlist\fP .RS 4 The group will be combined with a binary AND operation. That is: all bits that are set to 1 in the group AND in the combined groups so far will be preserved as 1. All other bits will be reset to 0. .RE .sp \fB^\fP\fImask\fP|\fB^\fP\fIlist\fP .RS 4 The group will be combined with a binary XOR operation. That is: all bits that are set to 1 in the group AND to 0 in the combined groups so far (or the other way around) will be set to 1. Bits that are set both to 1 or both to 0 will be reset to 0. .RE .sp \fB~\fP\fImask\fP|\fB~\fP\fIlist\fP .RS 4 All bits set to 1 in the group will be cleared (reset to 0) in the combined groups so far. .RE .SH "OPTIONS" .sp \fB\-w\fP \fInumber\fP, \fB\-\-width\fP \fInumber\fP .RS 4 The maximum number of bits in the masks handled by \fBbits\fP. The default is \fB8192\fP. Any bit larger than this number will be truncated. .RE .sp \fB\-h\fP, \fB\-\-help\fP .RS 4 Display help text and exit. .RE .sp \fB\-V\fP, \fB\-\-version\fP .RS 4 Display version and exit. .RE .SH "CONVERSION MODE" .sp One of the following conversion modes can be specified. If not specified, it defaults to \fB\-m\fP, \fB\-\-mask\fP. .sp \fB\-b\fP, \fB\-\-binary\fP .RS 4 Print the combined arguments as a binary mask value. .RE .sp \fB\-g\fP, \fB\-\-grouped\-mask\fP .RS 4 Print the combined arguments as a hexadecimal mask value in 32\-bit comma\-separated groups. .RE .sp \fB\-l\fP, \fB\-\-list\fP .RS 4 Print the combined arguments as a list of bit IDs. Consecutive IDs are compressed to ranges. .RE .sp \fB\-m\fP, \fB\-\-mask\fP .RS 4 Print the combined arguments as a hexadecimal mask value (default). .RE .SH "EXAMPLES" .sp .if n .RS 4 .nf .fam C ~$ 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 .fam .fi .if n .RE .SH "AUTHORS" .sp Robin Jarry. .SH "REPORTING BUGS" .sp For bug reports, use the \c .URL "https://github.com/util\-linux/util\-linux/issues" "issue tracker" "." .SH "AVAILABILITY" .sp The \fBbits\fP command is part of the util\-linux package which can be downloaded from \c .URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."