[Solved] Number generator


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Number generator
# 1  
Old 05-27-2013
[Solved] Number generator

Hello,

I want to generate numbers. between "0 to 100000" Thank you very much for your help.

Output:
Code:
0
25
50
75
100
125
.
.
100000


Last edited by tara123; 05-27-2013 at 07:44 AM.. Reason: .
# 2  
Old 05-27-2013
Code:
seq 0 25 100000

You may do this too, but it's gonna take a while:
Code:
i=0; while [ $i -le 100000 ]; do echo $i; i=`expr $i + 25`; done

These 2 Users Gave Thanks to balajesuri For This Post:
# 3  
Old 05-27-2013
I am assuming this is homework so here is some pseudo-code...

Code:
A) Start with a shebang line.

0) Zero a file if you want to to save it all. Ignore this line if you don't want a file...

1) Use a "for" loop that starts at 0, ends at 100000 and with a jump of 25.
2) Inside this loop "append" the zeroed file with each iteration. Ignore this line if you don't want a file...
3) Print the result(s) with or without newlines inside the terminal window.

Now searching this site AND Google are your friends...

EDIT, 16:00 UK local time:-

As others have already shown differing methods I will show you yet another using "seq 0 25 100000" as shown by balajesuri:-
Code:
#!/bin/bash
> number.txt ; for n in $( seq 0 25 100000 ) ; do printf "$n\n" >> number.txt ; printf "$n\n" ; done


Last edited by wisecracker; 05-27-2013 at 11:55 AM..
# 4  
Old 05-27-2013
Thank you very much Smilie
# 5  
Old 05-27-2013
Code:
awk ' BEGIN { for (i = 0; i <= 100000; i=i+25) print i } '

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Help with random pick 1000 number from range 1 to 150000

Hi, Do anybody knows how to use awk or any command to random print out 1000 number which start from range 1 to 150000? I know that "rand" in awk can do similar random selection. But I have no idea how to write a code that can random pick 1000 number from range 1 to 150000 :confused: ... (1 Reply)
Discussion started by: perl_beginner
1 Replies

2. Shell Programming and Scripting

[Solved] Counting The Number of Lines Between Values with Multiple Variables

Hey everyone, I have a bunch of lines with values in field 4 that I am interested in. If these values are between 1 and 3 I want it to count all these values to all be counted together and then have the computer print out LOW and the number of lines with those values in between 1 and 3,... (2 Replies)
Discussion started by: VagabondGold
2 Replies

3. Shell Programming and Scripting

[Solved] Script to concatenate 2 files with the same number of lines

Hi everyone, I have two files, namely: file1: file1Col1Row1;file1Col2Row1;file1Col3Row1 file1Col1Row2;file1Col2Row2;file1Col3Row2 file1Col1Row3;file1Col2Row3;file1Col3Row3file2: file2Col1Row1;file2Col2Row1;file2Col3Row1 file2Col1Row2;file2Col2Row2;file2Col3Row2... (0 Replies)
Discussion started by: gacanepa
0 Replies

4. Shell Programming and Scripting

[Solved] How to separate one line to mutiple line based on certain number of characters?

hi Gurus, I need separate a file which is one huge line to multiple lines based on certain number of charactors. for example: abcdefghi high abaddffdd I want to separate the line to multiple lines for every 4 charactors. the result should be abcd efgh i hi gh a badd ffdd Thanks in... (5 Replies)
Discussion started by: ken6503
5 Replies

5. Shell Programming and Scripting

[Solved] Sed error - multiple number options to `s' command

Hi All, I am having two files (file1 & file2) and a filelist.txt file below. file1: $$STRINGVAR1=5 $$STRINGVAR2=10 $$LAST_UPD_DT_TBL1=12/12/2010 12:00:00 $$STRINGVAR3=100 $$LAST_UPD_DT_TBL2=01/01/2010 12:00:00... (8 Replies)
Discussion started by: Chandru_Raj
8 Replies

6. UNIX for Dummies Questions & Answers

[Solved] Help correcting file with differing number of fields

Hi all, I have a tab separated file, and one of the fields is sub-delimited by colon. The problem is there can be zero to 4 colons within this field. When I try to change colons to tabs the result is a file with a differing number of fields. I want to go from: a:b:c:d:e a:b:c a:b:c:d:e a... (4 Replies)
Discussion started by: torchij
4 Replies

7. Shell Programming and Scripting

[Solved] Select the columns which have value greater than particular number

i have a file of the form 9488 14392 1 1.8586e-07 5702 7729 1 1.8586e-07 9048 14018 1 1.8586e-07 5992 12556 1 1.8586e-07 9488 14393 1 1.8586e-07 9048 14019 1 1.8586e-07 5992 12557 1 1.8586e-07 9488 14394 ... (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

8. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

9. Solaris

Does Solaris have a random number generator?

I am trying to find a way to generate random numbers within a shell script. Does Solaris have a utility that will generate random numbers? Thanks in advance. B (3 Replies)
Discussion started by: one_ring99
3 Replies
Login or Register to Ask a Question