Problem with ranges of numbers

Good day to everyone!

So, let's start :slight_smile:

I have a file with a numbers in some ranges
for example:

1 10
49 72
...

and this file need to transform to:

1
2
3
4
5
6
7
8
9
10
...

and so on

and in this file, ranges of numbers can be 19 digit numbers, 20-30 digit numbers

44447654329109275678 44447654329109275691
...

please, guys, help me

 
while read firstNum secondNum
do
     seq $firstNum $secondNum
done < input

no, it's not works
i need that script or something else throw this numbers in another file

so, i have one file with ranges, and i need second file with this "answers" =)

 
count=0
while read firstNum secondNum
do
     count=`echo $count + 1 | bc`
     seq $firstNum $secondNum >  $count.txt
done < input

hmmm
my system didn't know command seq: (No manual entry for seq.)

can you write me this script on awk?

 
bash-3.00$ cat 1.txt 
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

bash-3.00$ cat 2.txt 
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 

bash-3.00$ while read first second ; do count=`echo "$count +1" | bc`; echo $first $second | nawk '{for(i=$1;i<=$2;i++){print i}}' > $count.txt; done < test
 
 
bash-3.00$ cat test
10 30
25 50

syntax error on line 1, teletype
syntax error on line 1, teletype
syntax error on line 1, teletype
syntax error on line 1, teletype
syntax error on line 1, teletype
syntax error on line 1, teletype
syntax error on line 1, teletype
syntax error on line 1, teletype
syntax error on line 1, teletype
syntax error on line 1, teletype
syntax error on line 1, teletype
...

?

is your orginal file has some text also ?

from where the teletype is coming ?

you have to answer

i have made test file just like you do
and this script give these teletypes

strange.

i tested in solaris machine.

can you post the entire command that you have given. and the test file

try this one.

 
count=0;while read first second ; do count=`echo "$count +1" | bc`; echo $first $second | nawk '{for(i=$1;i<=$2;i++){print i}}' > $count.txt; done < test

hohoho!!!

this one is works
but it generate file.txt for each row

for example in test file I have
10 20
20 30

and it generates
1.txt which have
10
11
12
...
20
and second: 2.txt
20
21
22
...
30

can you help to collect all these rows in 1 file?

while read first second ; do echo $first $second | nawk '{for(i=$1;i<=$2;i++){print i}}' > output.txt; done < test

thanks

but... in test file I have:

100 200
10 19
45 77

and it only generate me:

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

replace

> output.txt

to

>> output.txt

1 Like

thanks itkamaraj!

but i forget about >>

while read first second ; do echo $first $second | nawk  '{for(i=$1;i<=$2;i++){print i}}' >> output.txt; done < test