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.


Install boxes for text mode ASCII-art box and comment drawing

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 60.4 kB of archives.
After this operation, 259 kB of additional disk space will be used.
Get:1 eoan/universe amd64 boxes amd64 1.3-1 [60.4 kB]
Fetched 60.4 kB in 1s (43.1 kB/s)
Selecting previously unselected package boxes.
(Reading database ... 239154 files and directories currently installed.)
Preparing to unpack .../archives/boxes_1.3-1_amd64.deb ...
Unpacking boxes (1.3-1) ...
Setting up boxes (1.3-1) ...
Processing triggers for man-db (2.8.7-3) ...

A note about CentOS/RHEL/Fedora users

RHEL or CentOS 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 and if you are using a CentOS/RHEL 8 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 install boxes

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

Install boxes on Mac OSX

Use the brew command:
brew install boxes

Windows installation

If you have choco (chocolatey package), you can now simply run the following command on Windows operating system:
choco install boxes.portable

Draw any kind of box around some given text

Type the following command:

echo "This is a test" | boxes

Of course we can specify the name of the design to use:

echo -e "\n\tVivek Gite\n\\n\" | boxes -d dog
Unix / Linux: Boxes Command To Draw Various Designs
Fig.01: Unix / Linux: Boxes Command To Draw Various Designs

How do I list all boxes 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:

65 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
     <\/>                  <\/>
    <\/>                    <\/>
     <\/>                  <\/>
        <\/>            <\/>

Positioning of text inside box

echo -n "This is a test" | boxes -d scroll-akn -a hcvc
The hcvc means “horizontally centered, vertically centered”. You can try the following options using bash for loop

# l - left alignment
# r - right alignment
# c - center alignment
for alignment in l r c
  echo "This is a test. I love pizza" | boxes -d dog -a $alignment
  echo ""

Boxes size specification

The syntax is

# set box box size (width w and/or height h) using the -s option
echo "The fool who knows he is a fool is that much wiser" | boxes -d dog -s 80
# set w to 90 and h to 11 #
echo "There is no fear for one whose mind is not filled with desires." | boxes -d peek -a c -s 90x11

Text Mode ASCII-art Box Examples for Linux and Unix desktop fun

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


And there you have it, text mode ASCII-art box which can draw any kind of box around its input text when using the CLI or vim text editor. See boxes man page for more info by typing the man command:
man boxes


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.

Start the discussion at

Historical Comment Archive

12 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
    $ sl

    after installing ‘sl’ packet, run ‘LS’ (type sl) 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
  7. Try piping the output of figlet to boxes:

    echo "abc" | figlet | boxes

    /*   //\         _          //\   */
    /*  |/_\|   __ _| |__   ___|/_\|  */
    /*  / _` | / _` | '_ \ / __/ _` | */
    /* | (_| || (_| | |_) | (_| (_| | */
    /*  \__,_| \__,_|_.__/ \___\__,_| */
    /*                                */

    Have a question? Post it on our forum!