Banner (Unix)

Last updated
banner
Operating system Unix and Unix-like
Type Command

The banner program on Unix and Unix-like operating systems outputs a large ASCII art version of the text that is supplied to it as its program arguments. One use of the command is to create highly visible separator pages for print jobs. [1]

Contents

Operation

Each argument is truncated at 10 characters and printed on a "line" of its own. To print multiple words on a single line, they must therefore be passed as a single argument, which is done from the shell by escaping or quoting the words as appropriate. [1]

A related and more flexible program is FIGlet, which can display text in different fonts and orientations. [2]

Implementation

The way that the program is implemented internally is antiquated. The character fonts used are hardwired into the program code itself, as statically initialized data structures. Two data structures are used. The first is a data table comprising a sequence of printing instructions that encode the bitmap for each character (in an encoding specific to the banner program). The second is an index into that table that indicates, for each character code, where the printing instructions for that character begin and end. [3]

Both data structures were hand-written. Spinellis observes that it is "difficult to come up with a more error-prone and unmaintainable data format". He observes a stark contrast between the source code of the banner program and automatically generated source code for encoding computer fonts into program data (using the 6-by-10 font data in the source code of the mac68k port of NetBSD for comparison). The automatically generated data are commented, documenting with ASCII art how the bit patterns were derived. The automatically generated data were generated from a bitmap file, itself generated using a bitmap creation/editing program with a graphical user interface. And the automatically generated data are organized in a straightforward and obvious manner — a fixed-length sequence of unencoded bytes for each glyph. [3]

Spinellis further observes that in modern computer systems it is seldom sensible to embed such data into the program executable image itself, the performance gains of doing so being negligible. Doing so makes it difficult to adapt the program to different locales, or to maintain the program. The more preferred approach in modern systems is to store such data in a separate data file, distinct from the program executable image file, or in a resource fork of the program, that the program reads at run-time. [3]

Versions

A partial list of versions:

Example output

From the terminal-oriented banner program:

 $ banner 'Hello!'#     #                                   ####     #  ######  #       #        ####    ####     #  #       #       #       #    #   ##########  #####   #       #       #    #    ##     #  #       #       #       #    ##     #  #       #       #       #    #   ####     #  ######  ######  ######   ####    ###

One letter from the printer-oriented banner program as usually found in BSD and derivatives:

 $ banner -w80 "a"#############################        ###################      ########################     #############         #####    #############           ####      ##  ######            ####           #####            ###            #####            ###           #######         ###           #########################################################################################################################################################

Display a continuous clock for approximately 1000 seconds: [lower-alpha 1] [lower-alpha 2]

 $ repeat 1000 sh -c '( clear ; date +" %H.%M.%S" | xargs banner ; sleep 1)'#     #####             #     #####          ####### #########    #     #           ##    #     #         #       ## #    #                # #          #         #       ##    ######             #     #####          ######  #######    #     #   ###      #    #         ###         #       ##    #     #   ###      #    #         ###   #     # #     ######   #####    ###    #####  #######   ###    #####   #####

See also

Notes

  1. If the following code is not run on a Zsh shell then the repeat command needs to be defined, [7] as in this code:
    function repeat(){for((i=0;i<$1;i++));doeval${*:2}}
    or that definition can be avoided by replacing the repeat command with a while loop, like this:
    $ i=0;while(($i<1000));do sh -c '( clear ; date +" %H.%M.%S" | xargs banner ; sleep 1 ; ((i=$i+1)))';done
  2. It can also be done using FIGlet utility with the substitution of banner with figlet -f banner

Related Research Articles

<span class="mw-page-title-main">ASCII art</span> Computer art form using text characters

ASCII art is a graphic design technique that uses computers for presentation and consists of pictures pieced together from the 95 printable characters defined by the ASCII Standard from 1963 and ASCII compliant character sets with proprietary extended characters. The term is also loosely used to refer to text-based visual art in general. ASCII art can be created with any text editor, and is often used with free-form languages. Most examples of ASCII art require a fixed-width font such as Courier for presentation.

Extended Binary Coded Decimal Interchange Code is an eight-bit character encoding used mainly on IBM mainframe and IBM midrange computer operating systems. It descended from the code used with punched cards and the corresponding six-bit binary-coded decimal code used with most of IBM's computer peripherals of the late 1950s and early 1960s. It is supported by various non-IBM platforms, such as Fujitsu-Siemens' BS2000/OSD, OS-IV, MSP, and MSP-EX, the SDS Sigma series, Unisys VS/9, Unisys MCP and ICL VME.

man page Unix software documentation

A man page is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs, formal standards and conventions, and even abstract concepts. A user may invoke a man page by issuing the man command.

In computing, tar is a computer software utility for collecting many files into one archive file, often referred to as a tarball, for distribution or backup purposes. The name is derived from "tape archive", as it was originally developed to write data to sequential I/O devices with no file system of their own. The archive data sets created by tar contain various file system parameters, such as name, timestamps, ownership, file-access permissions, and directory organization. POSIX abandoned tar in favor of pax, yet tar sees continued widespread use.

In software development, Make is a build automation tool that automatically builds executable programs and libraries from source code by reading files called Makefiles which specify how to derive the target program. Though integrated development environments and language-specific compiler features can also be used to manage a build process, Make remains widely used, especially in Unix and Unix-like operating systems.

<span class="mw-page-title-main">Newline</span> Special characters in computing signifying the end of a line of text

Newline is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character, or a sequence of characters, is used to signify the end of a line of text and the start of a new one.

uuencoding is a form of binary-to-text encoding that originated in the Unix programs uuencode and uudecode written by Mary Ann Horton at UC Berkeley in 1980, for encoding binary data for transmission in email systems.

FIGlet is a computer program that generates text banners, in a variety of typefaces, composed of letters made up of conglomerations of smaller ASCII characters. The name derives from "Frank, Ian and Glenn's letters".

The archiver, also known simply as ar, is a Unix utility that maintains groups of files as a single archive file. Today, ar is generally used only to create and update static library files that the link editor or linker uses and for generating .deb packages for the Debian family; it can be used to create archives for any purpose, but has been largely replaced by tar for purposes other than static libraries. An implementation of ar is included as one of the GNU Binutils.

xargs is a command on Unix and most Unix-like operating systems used to build and execute commands from standard input. It converts input from standard input into arguments to a command.

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.

rm (Unix) Unix command utility

rm is a basic command on Unix and Unix-like operating systems used to remove objects such as computer files, directories and symbolic links from file systems and also special files such as device nodes, pipes and sockets, similar to the del command in MS-DOS, OS/2, and Microsoft Windows. The command is also available in the EFI shell.

In computing, a shebang is the character sequence consisting of the characters number sign and exclamation mark at the beginning of a script. It is also called sharp-exclamation, sha-bang, hashbang, pound-bang, or hash-pling.

A Unicode font is a computer font that maps glyphs to code points defined in the Unicode Standard. The vast majority of modern computer fonts use Unicode mappings, even those fonts which only include glyphs for a single writing system, or even only support the basic Latin alphabet. Fonts which support a wide range of Unicode scripts and Unicode symbols are sometimes referred to as "pan-Unicode fonts", although as the maximum number of glyphs that can be defined in a TrueType font is restricted to 65,535, it is not possible for a single font to provide individual glyphs for all defined Unicode characters. This article lists some widely used Unicode fonts that support a comparatively large number and broad range of Unicode characters.

ManaGeR or MGR was an early windowing system originally designed and developed for Sun computers in 1984 by Stephen A. Uhler, then at Bellcore.

OTPW is a one-time password system developed for authentication in Unix-like operating systems by Markus Kuhn. A user's real password is not directly transmitted across the network. Rather, a series of one-time passwords is created from a short set of characters and a set of one-time tokens. As each single-use password can only be used once, passwords intercepted by a password sniffer or key logger are not useful to an attacker.

Toybox is a free and open-source software implementation of over 200 Unix command line utilities such as ls, cp, and mv. The Toybox project was started in 2006, and became a 0BSD licensed BusyBox alternative. Toybox is used for most of Android's command line tools in all currently supported Android versions, and is also used to build Android on Linux and macOS. All of the tools are tested on Linux, and many of them also work on BSD and macOS.

ptrace is a system call found in Unix and several Unix-like operating systems. By using ptrace one process can control another, enabling the controller to inspect and manipulate the internal state of its target. ptrace is used by debuggers and other code-analysis tools, mostly as aids to software development.

mandoc is a utility used for formatting man pages in BSD Operating Systems, specifically those written in the mdoc and man macro languages. Unlike the groff and older troff and nroff tools that are predominantly used for this purpose by tools such as man, mandoc focuses specifically on manuals and is not suitable for general-purpose type-setting.

cat (Unix) Unix command utility

cat is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to (con)catenate files. It has been ported to a number of operating systems.

References

  1. 1 2 Steve Moritsugu; Sanjiv Guha; James Edwards; David Pitts (2000). Practical UNIX. Que Publishing. pp.  220–221. ISBN   0-7897-2250-X.
  2. Arnold Robbins (2006). UNIX in a Nutshell. O'Reilly. pp.  24. ISBN   0-596-10029-9.
  3. 1 2 3 Diomidis Spinellis (2006). Code Quality. Adobe Press. pp. 70–71. ISBN   0-321-16607-8.
  4. Hatch (19 April 2004). "System V in AIX and Dynix/ptx". Archived from the original on 2009-05-26. Retrieved 2008-07-23.
  5. "AIX: Document 157-28-E" (PDF). zen77087.zen.co.uk.[ permanent dead link ]
  6. "Package: sysvbanner (1.0.15 and others)". Debian. Archived from the original on 2016-12-20. Retrieved 2010-05-06.
  7. Frankowski, Jędrzej (May 8, 2020). "Linux Commands – Repeat a Command n Times". Archived from the original on November 19, 2021. Retrieved January 22, 2022.

Further reading