Sponsored Content
The Lounge What is on Your Mind? Merry Xmas (special present inside) Post 303009984 by bakunin on Saturday 23rd of December 2017 10:21:10 PM
Old 12-23-2017
Merry Xmas (special present inside)

A Merry Xmas to all of you.

And, as a special present to vbe (he knows why) a little exercise:

Code:
#! /bin/ksh

pPrintSnow ()
{
typeset -i iLen=$1
while (( iLen )) ; do
     if ! (( RANDOM % 31 )) ; then
          printf "%1s" "."
     else
          printf "%1s" " "
     fi
     (( iLen -= 1 ))
done
return 0
}



pPrintTreeLine ()
{
typeset -i iWidth=$1
typeset -i iTermWidth=$COLUMNS
typeset -i iOffset=$(( (iTermWidth - iWidth)/2 ))

pPrintSnow $iOffset
while [ $iWidth -gt 0 ] ; do
     if !   (( RANDOM % 11 )) ; then
          printf "%s" "$(tput sgr0;tput bold)i$(tput sgr0;tput dim)"
     elif ! (( RANDOM %  7 )) ; then
          printf "%s" "O"
     elif ! (( RANDOM % 13 )) ; then
          printf "%s" "O"
     else
          printf "%s" "*"
     fi
     (( iWidth -= 1 ))
done
pPrintSnow $iOffset
printf "\n"

return 0
}



pPrintTrunk ()
{
typeset -i iTrunkWidth=$(( $1 - 2 ))
typeset -i iTrunkHeight=$2
typeset -i iTermWidth=$COLUMNS
typeset -i iOffset=$(( (iTermWidth - iTrunkWidth)/2 ))
typeset -i iCnt=0

if [ $iTrunkWidth -lt 1 ] ; then
     (( iTrunkWidth = 1 ))
     (( iOffset = (iTermWidth - iTrunkWidth ) / 2 ))
fi

while (( iTrunkHeight )) ; do
     if (( iTrunkHeight == 1 )) ; then
          printf "%${iOffset}s/" " "
     else
          printf "%${iOffset}s " " "
     fi
     (( iCnt = iTrunkWidth ))
     while (( iCnt )) ; do
          printf "%s" "|"
          (( iCnt -= 1 ))
     done
     if (( iTrunkHeight == 1 )) ; then
          printf '\\ \n'
     else
          printf '\n'
     fi
     (( iTrunkHeight -= 1 ))
done
return 0
}



# main ()
typeset -i iHeight=$1
typeset -i iCnt=0

eval $(resize)
tput dim
(( iCnt = 1 ))
while [ $iCnt -le $(( iHeight *2 )) ] ; do
     pPrintTreeLine $iCnt
     (( iCnt += 2 ))
done
pPrintTrunk $(( iHeight / 2 )) $(( iHeight / 5 ))
tput sgr0

exit 0

bakunin

Last edited by bakunin; 12-24-2017 at 01:31 AM..
This User Gave Thanks to bakunin For This Post:
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To find the count of records from tables present inside a file.

hi gurus, I am having a file containing a list of tables.i want to find the count of records inside thes tables. for this i have to connect into database and i have to put the count for all the tables inside another file i used the following loop once all the tablenames are inside the file. ... (1 Reply)
Discussion started by: navojit dutta
1 Replies

2. What is on Your Mind?

Merry Christmas

Merry Christmas and all best wishes to all fox in this forum salute from Croatia (0 Replies)
Discussion started by: solaris_user
0 Replies

3. Shell Programming and Scripting

want to remove comma present inside double qoute

Hi friends... I have a dat file like below:- test_file.dat abc,ttt,"""123,89.98",yyu,opp vvv,"23,76.68",w564,"54,98.87",985 i need the remove the comma present inside the double qoute as output:- out_test_file.dat abc,ttt,"""12389.98",yyu,opp vvv,"2376.68",w564,"5498.87",985... (6 Replies)
Discussion started by: gani_85
6 Replies

4. Shell Programming and Scripting

Replace Special Character With Next Present Byte

Hi, First find the special character, from the special character take next two bytes convert the bytes to decimal and replace with next present byte of decimal value times. E.g. Input: 302619ú1A? Output: 302619(3 spaces for ú1A)?????????????????????????? Thanks, Dines (27 Replies)
Discussion started by: dineshnak
27 Replies

5. What is on Your Mind?

Merry XMAS, happy holidays etc. everybody...

Have a laugh... https://www.youtube.com/watch?v=HZWQcl1C-c8 Bazza... (4 Replies)
Discussion started by: wisecracker
4 Replies
TPUT(1) 						    BSD General Commands Manual 						   TPUT(1)

NAME
tput, clear -- terminal capability interface SYNOPSIS
tput [-T term] attribute ... clear DESCRIPTION
The tput utility makes terminal-dependent information available to users or shell applications. When invoked as the clear utility, the screen will be cleared as if tput clear had been executed. The options to tput are as follows: -T The terminal name as specified in the termcap(5) database, for example, ``vt100'' or ``xterm''. If not specified, tput retrieves the ``TERM'' variable from the environment. The tput utility outputs a string for each attribute that is of type string; a number for each of type integer. Otherwise, tput exits 0 if the terminal has the capability and 1 if it does not, without further action. If an attribute is of type string, and takes arguments (e.g. cursor movement, the termcap ``cm'' sequence) the arguments are taken from the command line immediately following the attribute. The following special attributes are available: clear Clear the screen (the termcap(5) ``cl'' sequence). init Initialize the terminal (the termcap(5) ``is'' sequence). longname Print the descriptive name of the user's terminal type. reset Reset the terminal (the termcap(5) ``rs'' sequence). EXIT STATUS
The exit status of tput is as follows: 0 If the last attribute attribute argument is of type string or integer, its value was successfully written to standard output. If the argument is of type boolean, the terminal has this attribute. 1 This terminal does not have the specified boolean attribute. 2 Usage error. 3 No information is available about the specified terminal type. SEE ALSO
termcap(5), terminfo(5) STANDARDS
The tput utility conforms to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
The tput utility appeared in 4.4BSD. BUGS
The tput utility cannot really distinguish between different types of attributes. Some termcap entries depend upon having a '%' in them that is just a '%' and nothing more. Right now we just warn about them if they do not have a valid type declaration. These warnings are sent to stderr. BSD
June 15, 2002 BSD
All times are GMT -4. The time now is 02:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy