Indent (Unix)

Last updated
indent
Original author(s) David Willcox
Developer(s) David Ingamells, Carlo Wood, Joseph Arceneaux, Jim Kingdon, John Bridges
Initial releaseNovember 1976;47 years ago (1976-11)
Stable release
2.2.13 [1] / 20 March 2023;10 months ago (20 March 2023)
Repository
Written in C
Operating system Cross-platform
Type source-code-reformat tool
License GNU: GPL-3.0-or-later [2]
WebsiteGNU: gnu.org/software/indent/

indent is a Unix utility that reformats C and C++ code in a user-defined indentation style and coding style. Support for C++ code is minimal. [3]

Contents

The original version of indent was written by David Willcox at the University of Illinois in November 1976. It was incorporated into 4.1BSD in October 1982. [4] GNU indent was first written by Jim Kingdon in 1989. The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities. [5]

Examples of usage

The following command

$indent-st-bap-bli0-i4-l79-ncs-npcs-npsl-fca-lc79-fc1-ts4some_file.c 

indents some_file.c in a style resembling BSD/Allman style and writes the result to the standard output.

GNU indent

GNU indent is the GNU Project's version of indent. A different indentation style, the GNU style, is used by default. [6]

Related Research Articles

uniq is a utility command on Unix, Plan 9, Inferno, and Unix-like operating systems which, when fed a text file or standard input, outputs the text with adjacent identical lines collapsed to one, unique line of text.

ls Command to list files and directories in Unix and Unix-like operating systems

In computing, ls is a command to list computer files and directories in Unix and Unix-like operating systems. It is specified by POSIX and the Single UNIX Specification.

In the Unix operating system, shar is an archive format created with the Unix shar utility. A shar file is a type of self-extracting archive, because it is a valid shell script, and executing it will recreate the files. To extract the files, only the standard Unix Bourne shell sh is usually required.

basename is a standard computer program on Unix and Unix-like operating systems. When basename is given a pathname, it will delete any prefix up to the last slash ('/') character and return the result. basename is described in the Single UNIX Specification and is primarily used in shell scripts.

patch (Unix) Unix utility to apply changes to text files

The computer tool patch is a Unix program that updates text files according to instructions contained in a separate file, called a patch file. The patch file is a text file that consists of a list of differences and is produced by running the related diff program with the original and updated file as arguments. Updating files with patch is often referred to as applying the patch or simply patching the files.

dd is a command-line utility for Unix, Plan 9, Inferno, and Unix-like operating systems and beyond, the primary purpose of which is to convert and copy files. On Unix, device drivers for hardware and special device files appear in the file system just like normal files; dd can also read and/or write from/to these files, provided that function is implemented in their respective driver. As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining a fixed amount of random data. The dd program can also perform conversions on the data as it is copied, including byte order swapping and conversion to and from the ASCII and EBCDIC text encodings.

join is a command in Unix and Unix-like operating systems that merges the lines of two sorted text files based on the presence of a common field. It is similar to the join operator used in relational databases but operating on text files.

wc (Unix) Unix command utility

wc is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. The program reads either standard input or a list of computer files and generates one or more of the following statistics: newline count, word count, and byte count. If a list of files is provided, both individual file and total statistics follow.

cksum Unix command

cksum is a command in Unix and Unix-like operating systems that generates a checksum value for a file or stream of data. The cksum command reads each file given in its arguments, or standard input if no arguments are provided, and outputs the file's 32-bit cyclic redundancy check (CRC) checksum and byte count. The CRC output by cksum is different from the CRC-32 used in zip, PNG and zlib.

df (Unix) Standard Unix command

df is a standard Unix command used to display the amount of available disk space for file systems on which the invoking user has appropriate read access. df is typically implemented using the statfs or statvfs system calls.

paste is a Unix command line utility which is used to join files horizontally by outputting lines consisting of the sequentially corresponding lines of each file specified, separated by tabs, to the standard output.

nl is a Unix utility for numbering lines, either from a file or from standard input, reproducing output on standard output.

cmp (Unix)

In computing, cmp is a command-line utility on Unix and Unix-like operating systems that compares two files of any type and writes the results to the standard output. By default, cmp is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported. The command is also available in the OS-9 shell.

whoami Command on various operating systems

In computing, whoami is a command found on most Unix-like operating systems, Intel iRMX 86, every Microsoft Windows operating system since Windows Server 2003, and on ReactOS. It is a concatenation of the words "Who am I?" and prints the effective username of the current user when invoked.

sum is a legacy utility available on some Unix and Unix-like operating systems. This utility outputs a 16-bit checksum of each argument file, as well as the number of blocks they take on disk. Two different checksum algorithms are in use. POSIX abandoned sum in favor of cksum.

In computing, which is a command for various operating systems used to identify the location of executables. The command is available in Unix and Unix-like systems, the AROS shell, for FreeDOS and for Microsoft Windows. The functionality of the which command is similar to some implementations of the type command. POSIX specifies a command named command that also covers this functionality.

dirname is a standard computer program on Unix and Unix-like operating systems. When dirname is given a pathname, it will delete any suffix beginning with the last slash ('/') character and return the result. dirname is described in the Single UNIX Specification and is primarily used in shell scripts.

The csplit command in Unix and Unix-like operating systems is a utility that is used to split a file into two or more smaller files determined by context lines.

fold is a Unix command used for making a file with long lines more readable on a limited width computer terminal by performing a line wrap.

On Unix-like computer systems, seq is a utility for generating a sequence of numbers.

References

  1. "NEWS - indent.git" . Retrieved 16 May 2023.
  2. GNU Savannah. "GNU indent" . Retrieved 2023-10-30. License: GNU General Public License v3 or later
  3. "indent: Indent and Format C Program Source". www.gnu.org. Retrieved 2019-08-16.
  4. Dickey, Thomas (2017). "CINDENT - C-language formatter". Invisible Island. Retrieved 2019-04-22.
  5. "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.
  6. GNU Indent Manual