Skip to main content

Thread: drawing a shape with shell script


i'm trying draw tree in following form

code:
    *         ***    *****   *******  *********
as can see need both spaces, , "*" stars in every line, can't quite way want
code:
#!/bin/bash    display_tree() {  	local rows=$1  	local columns=$2    	for ((i=0; i<$rows; i++))  	do  		#spaces loop  		for ((j=0; j<$columns; j++))  		do  			echo -n " "  			#drawing tree loop  			for ((a=0; a<$(($i + 1)); a++))  			do  				echo -n "*"  			done  		done  	echo   	done  }    if [ $# -eq 2 ];  	display_tree $1 $2  else  	echo "usage: $0 rows columns"  fi

code:
$ n=6; row=""; $ for(( i=0; i<n; i++ )); row="$row "; done; row="${row%?}*"; for(( i=0; i<n; i++ )); echo "$row"; row="${row#?}**"; done      *     ***    *****   *******  ********* ***********


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] drawing a shape with shell script


Ubuntu

Comments

Popular posts from this blog

Could not place because the source rectangle is empty

Thread: Using smartcard reader with vpnc

Adobe Font Folio 7.0 or just 7?