kaisalhassani
Programmer
Hi
I would like to draw a box in unix scripting shell and have text in it.
thank you
I would like to draw a box in unix scripting shell and have text in it.
thank you
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#/bin/bash
s="foobar as barfoo";
len=$((${#s}+4));
for i in $(seq 1 $len); do echo -n '*'; done;
echo; echo "* "$s" *";
for i in $(seq 1 $len); do echo -n '*'; done;
echo
echo "#-----#"
echo "| |"
echo "| txt |"
echo "| |"
echo "#-----#"
Previously posted by columb
#!/bin/ksh
draw_line ()
{
COUNT=0
while [[ $COUNT -lt $1 ]]
do
echo " \c"
(( COUNT += 1 ))
done
echo "$3\c"
COUNT=0
while [ $COUNT -le $2 ]
do
echo "$4\c";
(( COUNT += 1 ))
done
echo "$3"
}
DOWN=$1
LEFT=$2
WIDTH=$3
DEPTH=$4
(( WIDTH -= 2 ))
(( DEPTH -= 2 ))
tput clear
KOUNT=0
while [ $KOUNT -le $DOWN ]
do
echo
(( KOUNT += 1 ))
done
draw_line $LEFT $WIDTH "+" "-"
KOUNT=0
while [ $KOUNT -lt $DEPTH ]
do
draw_line $LEFT $WIDTH "|" " "
(( KOUNT += 1 ))
done
draw_line $LEFT $WIDTH "+" "-"