Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Draw a box in unix shell

Status
Not open for further replies.

kaisalhassani

Programmer
Sep 2, 2007
8
GB
Hi

I would like to draw a box in unix scripting shell and have text in it.

thank you
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Code:
echo "#-----#"
echo "|     |"
echo "| txt |"
echo "|     |"
echo "#-----#"

or

Code:
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 "+" "-"

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top