loop to display whatever number use types


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting loop to display whatever number use types
# 1  
Old 12-02-2011
loop to display whatever number use types

sorry couldnt think of a proper title lol

ok i have the following script it asks the user how many html tags they want. Im not sure how to display 2 tags if the user eneters the want only 2 tags

tags as in <p></p> or <h1></h1>

Code:
read -p "How many tags" tags1

if [ $tags1 -ge 1 ]
then
echo "<$tags1> $paragraph <$tags1>
end if

so if i enter 2 in my script it should display this twice

Code:
<$tags1> $paragraph <$tags1>

# 2  
Old 12-02-2011
Code:
read -p "How many tags" tags1

if [ $tags1 -ge 1 ]
then
     for i in {1..$tags1}
     do     
         echo "<$tags1> $paragraph <$tags1>
    done
end if

bash only.
# 3  
Old 12-02-2011
Code:
for i in {1..$tags1}

what does this line mean and why is it it a 1 and 2 dots?
# 4  
Old 12-05-2011
{N..M} is a shell sequence expression, which generates a numeric or char sequence between N and M (inclusive).
Code:
echo {1..3}
1 2 3

If your shell doesn't support it you can use seq.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Display number from 10 to 1 using shell programming in while loop

display number from 10 to 1 using shell programming in while loop and using read n numbers (2 Replies)
Discussion started by: aswin
2 Replies

2. Homework & Coursework Questions

Display number from 10 to 1 using shell programming in while loop

echo "enter the number" read n while do echo "$n" let n-- done (1 Reply)
Discussion started by: aswin
1 Replies

3. UNIX for Dummies Questions & Answers

display types of files using metacharacters

1) I want to display all the files in a directory that start with the word chapter, are followed by a digit 1,2,6,8, or 9 and end with .eps or .prn so I came up with this file ~/temp/chapter.eps ~/temp/chapter.prn but is there a better way, i.e. combining both file types into the command? ... (2 Replies)
Discussion started by: dunsta
2 Replies

4. Ubuntu

display the mounted file system types

how can i list/display the mounted partitions in Ubunutu, mount command just display the devices but not the file system used. (4 Replies)
Discussion started by: XP_2600
4 Replies

5. Shell Programming and Scripting

Search two file types within a for loop

I need to search for a csv and a dat file within a for loop then output them to a log table. I can do it individually but I want them together. See below code: check csv count=0 for file in $(ls *.csv) ; do count=`expr $count + 1` ... (4 Replies)
Discussion started by: Pablo_beezo
4 Replies

6. Shell Programming and Scripting

display unique number

Hi, how i can display all the unique number from my random number script below; #!/usr/bin/perl use strict; my @alphanum = ( 'A' .. 'Z', 'a' .. 'z', 0 .. 9); my $random = join('', map($alphanum,(1..5))); print "$random\n"; Thank You. (1 Reply)
Discussion started by: malaysoul
1 Replies

7. Solaris

Display Serial Number

Hello, I am running Solaris 9 and I need to display the serial number of my machine. How can I do this? Here is my machine info: SunOS birch 5.9 Generic_118558-09 sun4u sparc SUNW,Sun-Fire-V240 Thank you, David (5 Replies)
Discussion started by: dkranes
5 Replies

8. Shell Programming and Scripting

display number of subdirectories

Can anyone tell me what command would display the number of subdirectories in the current or given location? (2 Replies)
Discussion started by: jjamd64
2 Replies

9. Programming

how i display number in words

helo i want to implement the following concept in my project write a c/c++ algorithm for : accept a number from the user not greater than 6 digits and display the number in words i.e. if the input from the user is 18265 then the output should be Eighteen Thousand Two Hundred Sixty Five. if the... (3 Replies)
Discussion started by: amitpansuria
3 Replies

10. UNIX for Dummies Questions & Answers

How to use ps to display processor number

I'm on a Unix 5.2 server and I want to be able to see my processes to verify they are active and which processor they are running on. ps -l will show me the status of process (active/stopped/idle) but to see which processor the process is assigned to I don't know how. Manpages show -o... (1 Reply)
Discussion started by: tumblez
1 Replies
Login or Register to Ask a Question