LinuxCommandLibrary

cb

Convert between character encodings

TLDR

Show all clipboards

$ cb
copy

Copy a file to the clipboard
$ cb copy [path/to/file]
copy

Copy some text to the clipboard
$ cb copy "[Some example text]"
copy

Copy piped data to the clipboard
$ echo "[Some example text]" | cb
copy

Paste clipboard content
$ cb paste
copy

Pipe out clipboard content
$ cb | cat
copy

Show clipboard history
$ cb history
copy

Show clipboard information
$ cb info
copy

SYNOPSIS

cb [-j] [file ...]

PARAMETERS

-j
    Join continued ('split') lines into single lines

DESCRIPTION

Cb is a minimalist C language source code formatter for Unix-like systems. It reads C programs from specified files or standard input and outputs beautified versions to standard output. Cb standardizes indentation, aligns code structures like declarations and statements, breaks long lines appropriately, and improves overall readability without altering the program's semantics.

The tool excels in simplicity and speed, making it suitable for quick formatting of legacy or simple C code. It automatically handles common C constructs such as functions, loops, conditionals, and braces. However, due to its basic parsing, it may not perfectly format complex preprocessor directives or non-standard extensions.

Typically invoked in pipelines or scripts, cb helps maintain consistent style in codebases. Redirect output to files for in-place editing, e.g., cb input.c > output.c. Ideal for developers preferring lightweight tools over feature-heavy alternatives.

CAVEATS

Limited parsing may mishandle complex macros, nested structures, or K&R C; always review output. Writes only to stdout—no in-place editing.

EXIT STATUS

0 on success; >0 if parsing or I/O errors occur.

EXAMPLE

cb -j program.c > program_formatted.c
Formats program.c joining split lines.

HISTORY

Originated in early 1980s Unix tools, inspired by 'Software Tools' book; written by J. F. Reiser. Ported to various BSD/Linux systems; remains in minimal toolsets for legacy support.

SEE ALSO

indent(1)

Copied to clipboard