Linux / Unix Desktop Fun: Text Mode ASCII-art Box and Comment Drawing

last updated in Categories Linux, Linux desktop

Boxes command is a text filter and a little known tool that can draw any kind of ASCII art box around its input text or code for fun and profit. You can quickly create email signatures, or create regional comments in any programming language. This command was intended to be used with the vim text editor, but can be used with any text editor which supports filters, as well as from the command line as a standalone tool.


Task: Install boxes

Use the apt-get command or apt command to install boxes under a Debian / Ubuntu Linux:
$ sudo apt-get install boxes
Sample outputs:

[sudo] password for vivek: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 66.6 kB of archives.
After this operation, 194 kB of additional disk space will be used.
Get:1 artful/universe amd64 boxes amd64 1.2-2 [66.6 kB]
Fetched 66.6 kB in 2s (27.5 kB/s)
Selecting previously unselected package boxes.
(Reading database ... 201669 files and directories currently installed.)
Preparing to unpack .../archives/boxes_1.2-2_amd64.deb ...
Unpacking boxes (1.2-2) ...
Setting up boxes (1.2-2) ...
Processing triggers for man-db ( ...

CentOS / Fedora Linux users, use the yum command to install boxes (first enable EPEL repo as described here on a CentOS/RHEL 6.x, if you are using a CentOS/RHEL 7.x see this page to enable EPEL repo):
# yum install boxes
Sample outputs:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
Resolving Dependencies
--> Running transaction check
---> Package boxes.x86_64 0:1.1.1-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
 Package         Arch             Version                 Repository      Size
 boxes           x86_64           1.1.1-4.el7             epel            66 k
Transaction Summary
Install  1 Package
Total download size: 66 k
Installed size: 157 k
Is this ok [y/d/N]: y
Downloading packages:
boxes-1.1.1-4.el7.x86_64.rpm                              |  66 kB   00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : boxes-1.1.1-4.el7.x86_64                                    1/1 
  Verifying  : boxes-1.1.1-4.el7.x86_64                                    1/1 
  boxes.x86_64 0:1.1.1-4.el7                                                   

Fedora Linux user try dnf command:
$ sudo dnf install boxes
FreeBSD user can use the port as follows:
cd /usr/ports/misc/boxes/ && make install clean
Or, add the package using the pkg_add command:
# pkg install boxes

Draw any kind of box around some given text

Type the following command:

echo "This is a test" | boxes

Or specify the name of the design to use:

echo -e "\n\tVivek Gite\n\\n\" | boxes -d dog

Sample outputs:

Unix / Linux: Boxes Command To Draw Various Designs
Fig.01: Unix / Linux: Boxes Command To Draw Various Designs

How do I list all designs?

The syntax is:

boxes option
pipe | boxes options
echo "text" | boxes -d foo
boxes -l

The -d design option sets the name of the design to use. The syntax is:

echo "Text" | boxes -d design
pipe | boxes -d design

The -l option list designs. It produces a listing of all available box designs in the config file, along with a sample box and information about it’s creator:

boxes -l
boxes -l | more
boxes -l | less

Sample outputs:

43 Available Styles in "/etc/boxes/boxes-config":

ada-box (Neil Bird ):

    --           --
    --           --

ada-cmt (Neil Bird ):

    -- regular Ada
    -- comments

boy (Joan G. Stark ):

                   / .===. \
                   \/ 6 6 \/
                   ( \___/ )
     /                                   \
    |   joan stark   |
    | |
     \_______________________ooo_________/  jgs
                    |  |  |
                    |_ | _|
                    |  |  |
                   (__/ \__)

output truncated

How do I filter text via boxes while using vi/vim text editor?

You can use any external command with vi or vim. In this example, insert current date and time, enter:
:r !date
You need to type above command in Vim to read the output from the date command. This will insert the date and time after the current line:

Tue Jun 12 00:05:38 IST 2012

You can do the same with boxes command. Create a sample shell script or a c program as follows:

Purpose: Backup mysql database to remote server.
Author: Vivek Gite
Last updated on: Tue Jun, 12 2012

Now type the following (move cursor to the second line i.e. line which starts with “Purpose: …”)


And voila you will get the output as follows:

/* Purpose: Backup mysql database to remote server. */
/* Author: Vivek Gite           */
/* Last updated on: Tue Jun, 12 2012                */

This video will give you an introduction to boxes command:

Getting more info about the command:
$ boxes --help
Sample outputs:

boxes - draws any kind of box around your text (and removes it)
        (c) Thomas Jensen <>
        Web page:
Usage:  boxes [options] [infile [outfile]]
        -a fmt   alignment/positioning of text inside box [default: hlvt]
        -c str   use single shape box design where str is the W shape
        -d name  box design [default: first one in file]
        -f file  configuration file
        -h       print usage information
        -i mode  indentation mode [default: box]
        -k bool  leading/trailing blank line retention on removal
        -l       list available box designs w/ samples
        -m       mend box, i.e. remove it and redraw it afterwards
        -p fmt   padding [default: none]
        -r       remove box
        -s wxh   box size (width w and/or height h)
        -t str   tab stop distance and expansion [default: 8e]
        -v       print version information

See also

  • boxes man page


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

13 comment

  1. rmalek@moil:~$ cowsay Your boxes are no match for my cow power!

    / Your boxes are no match for my cow 
     power!                             /
                (__)       )/
                    ||----w |
                    ||     ||


  2. Thak you for sharing with me boxes
    but +1 for cowsay – I’ve used that magic cow for a years and next entry is one of first when I bring-up a new machine

    grep cow ~/.bashrc
    fortune /usr/share/games/fortunes/bg | cowsay -b -f /usr/share/cowsay/cows/tux.cow -n
  3. @indu

    It was just a demo. Not a real script 😛 Also, I’m too lazy to create and upload updated video.

    @all, yes cowsay rocks, but this tool offer other options too.

    Appreciate all comments.

  4. Try this,
    $ apt-get install sl
    $ LS
    after installing ‘sl’ packet, run ‘LS’ command, It display animated train running on your terminal. 🙂

  5. @beparas
    Thats funny 🙂

    Thanks for the sample outputs in the articles you write here. Great idea.

  6. dir='/usr/share/cows/'
    file=`/bin/ls -1 "$dir" | sort --random-sort | head -1`
    cow=$(echo "$file" | sed -e "s/.cow//")
    fortune -a | cowsay -f $cow

    Have a question? Post it on our forum!