I have on script1 which provide the output text...
I want to make box around that output to make it more beautiful.
As the output lines for the script1 are not fixed, I can not hard code the design pattern.
Can anyone provide me the code to make design.?
|---------------------------------------------|
| This is output of script1 |
| Wel come to computer designing |
| Your name XYZ and qualifications are ABC |
| Thanks you |
|----------------------------------------------|
Any other fancy design pattern can also work.
Thanks in advance,
You can download at: Fedora People - sea.fedorapeople.org
NOTE: Eventhough i packaged it for Fedora, the tarball works for all (to me known/used) *nix systems.
Just place the files where the README tells.
I wrote a shells script that takes the output from stdin and surrounds it with #s.
Hope this helps.
#!/bin/bash
#
#
# read from stdin and dump to a temporary file
TMPFILE="/tmp/${0##*/}.$$"
while read -r INPUT
do
echo $INPUT >> $TMPFILE
done
# get the length of the longest line
END=$(cat $TMPFILE | awk '{if(length($0)>l) l=length($0);}END{print l}')
# add 1 to our end length
LASTCHAR=$(expr $END + 1)
# create header and footer
FHLENGTH=$(expr $LASTCHAR + 5)
HEADER=$(seq -s "#" "$FHLENGTH" | sed 's/[0-9]//g')
FOOTER=$(seq -s "#" "$FHLENGTH" | sed 's/[0-9]//g')
# make the output pretty
echo $HEADER
while read OUTPUT
do
printf "%1s %-${LASTCHAR}s %1s\n" "#" "$OUTPUT" "#"
done < $TMPFILE
echo $FOOTER
# done
rm -f $TMPFILE
exit 0
Run like so:
./script1 | ./makePretty.sh
% ./s1
Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution : Debian GNU/Linux 5.0.8 (lenny, workstation)
bash GNU bash 3.2.39
boxes version 1.0.1a
-----
Input data file data1:
I have on script1 which provide the output text...
I want to make box around that output to make it more beautiful.
As the output lines for the script1 are not fixed, I can not hard
code the design pattern.
Can anyone provide me the code to make design.
-----
Results:
+-------------------------------------------------------------------+
| I have on script1 which provide the output text... |
| I want to make box around that output to make it more beautiful. |
| As the output lines for the script1 are not fixed, I can not hard |
| code the design pattern. |
| Can anyone provide me the code to make design. |
+-------------------------------------------------------------------+