How to creat a half-triangle in bash(Ubuntu)?


 
Thread Tools Search this Thread
Operating Systems Linux Ubuntu How to creat a half-triangle in bash(Ubuntu)?
# 1  
Old 03-13-2013
How to creat a half-triangle in bash(Ubuntu)?

how to create a half-triangle like this
and that will accept an input from the user, Dimension of the triangle will be based on the users input.

example:
enter the dimension: 5

*****

-****

--***

---**

----*

thankyou

Last edited by carljoses; 03-13-2013 at 05:41 AM..
# 2  
Old 03-13-2013
Is this a homework question?
# 3  
Old 03-13-2013
Not sure why you need the underscores but if is the asterisks that are important then you could try using escape codes to do it...

You will need to do the _animation_ yourself as it looks like a homework question...

the simple case however is:-
Code:
horiz=23
vert=11

printf "\x1B["$vert";"$horiz"f*"

Will print an asterisk at position 23 across and 11 down in a terminal window...

This is for bash, and might work on other shells...

Bazza, G0LCU...
# 4  
Old 03-13-2013
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ubuntu 16 Bash strange output

Hello, I work in Ubuntu 16.04, I am new to Bash and something is wrong with my script, please help. I have a few hundreds of subjects data (like subj003.nii.gz, subj012.nii.gz etc. up to subj567.nii.gz) in a directory /usr/afewmoredirectories/subjects. I may run for each subject a command... (5 Replies)
Discussion started by: lim-lim
5 Replies

2. Shell Programming and Scripting

need help in writing shell script to generate pascal's triangle

Hi :) I am learning shell scripting, I need help, I would like to have a script that produces pascal's triangle as shown in the picture http://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Pascal%27s_triangle_5.svg/250px-Pascal%27s_triangle_5.svg.png plz, help it's urgent thanks in... (1 Reply)
Discussion started by: angel1
1 Replies

3. Programming

help me with perl script that creat pdf

Hi, I have one xml file, I extracted some comments and saved in pdf file.I written code like this #!/usr/bin/perl use warnings; use strict; use PDF::API2; use PDF::API2::Page; use XML::LibXML::Reader; use Data::Dumper; my $file; open( $file, 'formal.xml'); my $reader =... (1 Reply)
Discussion started by: veerubiji
1 Replies

4. Debian

creat image for the new kernel

Hello friends, I have compiled the kernel . But now i am facing the problem as to how we can create the initrd.img for the specific kernel. I was compiling the 2.6.29 kernel. to create initrd.img for 2.6.29 what i did is : cd /boot mkinitramfs-kpkg -o initrd.img-2.6.29 2.6.29... (2 Replies)
Discussion started by: pradeepreddy
2 Replies

5. Solaris

creat flash archive

I want take a flash backup by flar command for specific files like: / , /boot, /tmp I am trying this command but its not working # flar -n archive1 -f /,/boot,/tmp -F -c /home/arc1.flar Please can any body help me __.____._ (2 Replies)
Discussion started by: kmuqalled
2 Replies

6. Shell Programming and Scripting

shell script to print '*' triangle

plz tell me how to print * triangle like this * ** *** **** ***** (12 Replies)
Discussion started by: akash
12 Replies

7. AIX

Creat a File with a Specific Size

Hi everybody, Is there a command that can create a new file with a specific size? Thanks in advance. (3 Replies)
Discussion started by: aldowsary
3 Replies

8. Programming

Creat-Crontab

Dear All, Please any send the idea and designing for creating the crontab in c Thank in advanced (2 Replies)
Discussion started by: dhinesh
2 Replies
Login or Register to Ask a Question