Banner (Unix)

bannerOperating 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

* 1 Operation
* 2 Implementation
* 3 Versions
* 4 Example output
* 5 See also
* 6 Notes
* 7 References
* 8 Further reading
* 9 External links

## 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:

* By AT&T, in UNIX System V.[4][5][6]
* By Cedar Solutions. Runs on modern Linux systems as of 2008. Prints horizontally only with a fixed size.
* By Mary Ann Horton at the University of California Berkeley, distributed as part of the bsdmainutils package, under the name printerbanner. Runs on modern Linux, GNU Hurd, and Mac OS X systems as of 2008. Prints vertically with variable size font.

## 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

* FIGlet – a Linux utility that provided the same functionality when the banner font is selected

## 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++)); do
eval ${*: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`

## References

1. ↑ 1.0 1.1 Steve Moritsugu; Sanjiv Guha; James Edwards; David Pitts (2000). Practical UNIX. Que Publishing. pp. 220–221. ISBN 0-7897-2250-X. https://archive.org/details/practicalunix00mori_1/page/220.
2. ↑ Arnold Robbins (2006). UNIX in a Nutshell. O'Reilly. pp. 24. ISBN 0-596-10029-9. https://archive.org/details/unixinnutshell00robb/page/24.
3. ↑ 3.0 3.1 3.2 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. https://web.archive.org/web/20090526232236/http://www.zen77087.zen.co.uk/nug/alleg/sysv-aix-dynix.shtml. Retrieved 2008-07-23.
5. ↑ "AIX: Document 157-28-E". http://www.zen77087.zen.co.uk/nug/doc/IBM-157-28-E.pdf. [yes|permanent dead link|dead link}}]
6. ↑ "Package: sysvbanner (1.0.15 and others)". Debian. Archived from the original on 2016-12-20. https://web.archive.org/web/20161220235930/https://packages.debian.org/stable/sysvbanner. Retrieved 2010-05-06.
7. ↑ Frankowski, Jędrzej (May 8, 2020). "Linux Commands – Repeat a Command n Times". https://www.baeldung.com/linux/repeat-command.

## Further reading

* Amir Afzal (2008). "The banner command". UNIX Unbounded. Prentice Hall. pp. 462–463. ISBN 0-13-119449-6.

## External links

* `banner(6)` – 4.2BSD Games Manual
* `banner(6)` – FreeBSD Games Manual

* v
* t
* e

Unix command-line interface programs and shell builtins

File system|

* cat
* chmod
* chown
* chgrp
* cksum
* cmp
* cp
* dd
* du
* df
* file
* fuser
* ln
* ls
* mkdir
* mv
* pax
* pwd
* rm
* rmdir
* split
* tee
* touch
* type
* umask

Processes|

* at
* bg
* crontab
* fg
* kill
* nice
* ps
* time

User environment|

* env
* exit
* logname
* mesg
* talk
* tput
* uname
* who
* write

Text processing|

* awk
* basename
* comm
* csplit
* cut
* diff
* dirname
* ed
* ex
* fold
* head
* iconv
* join
* m4
* more
* nl
* paste
* patch
* printf
* sed
* sort
* strings
* tail
* tr
* uniq
* vi
* wc
* xargs

Shell builtins|

* alias
* cd
* echo
* test
* unset
* wait

Searching|

* find
* grep

Documentation|

* man

Software development|

* ar
* ctags
* lex
* make
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* expr
* lp
* od
* sleep
* true and false

* Categories
* Standard Unix programs
* Unix SUS2008 utilities
* List

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Banner (Unix). Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Banner_(Unix)&oldid=446332"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template