Problem with ranges of numbers


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problem with ranges of numbers
# 8  
Old 07-04-2011
is your orginal file has some text also ?

from where the teletype is coming ?

you have to answer
# 9  
Old 07-04-2011
i have made test file just like you do
and this script give these teletypes
# 10  
Old 07-04-2011
strange.

i tested in solaris machine.

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

try this one.

Code:
 
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

# 11  
Old 07-04-2011
Quote:
Originally Posted by itkamaraj
strange.

i tested in solaris machine.

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

try this one.

Code:
 
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?
# 12  
Old 07-04-2011
Code:
while read first second ; do echo $first $second | nawk '{for(i=$1;i<=$2;i++){print i}}' > output.txt; done < test

# 13  
Old 07-04-2011
Quote:
Originally Posted by itkamaraj
Code:
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:

Code:
100 200
10 19
45 77

and it only generate me:

Code:
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

# 14  
Old 07-04-2011
replace

> output.txt

to

>> output.txt
This User Gave Thanks to itkamaraj For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print numbers between two number ranges

Hi, I have a list.txt file with number ranges and want to print/save new all.txt file with all the numbers and between the numbers. == list.txt == 65936 65938 65942 && 65943 65945 ... (7 Replies)
Discussion started by: AK47
7 Replies

2. Shell Programming and Scripting

Values between ranges

Hi, I have two files file1 chr1_22450_22500 chr2_12300_12350 chr1_34500_34550 file2 11000_13000 15000_19000 33000_44000 If the file 1 ranges fall between file2 ranges then assign the value of file2 in column 2 to file1 output: chr2_12300_12350 11000_13000 chr1_34500_34550 ... (7 Replies)
Discussion started by: Diya123
7 Replies

3. Shell Programming and Scripting

Problem with numbers in exponential format

Hi I have a shell scribt with some numbers in exponential format, for example, "1.23456789E +01" Now I would like to bring these numbers into a format without the E. Can someone help me Thanks Flo ---------- Post updated at 10:07 AM ---------- Previous update was at 09:14 AM... (1 Reply)
Discussion started by: sbfly
1 Replies

4. UNIX for Dummies Questions & Answers

Magic numbers string/B problem

Hello, In manpage magic(5) " The “B” flag compacts whitespace in the target, which must contain at least one whitespace character. If the magic has n consecutive blanks, the target needs at least n consecutive blanks to match. The “b” flag treats every blank in the target as an optional... (4 Replies)
Discussion started by: segmentation
4 Replies

5. UNIX for Dummies Questions & Answers

Magic numbers '&' operator problem

Hello everyone, on the man page of "magic(5)" There is explanation "&, to specify that the value from the file must have set all of the bits that are set in the specified value" . My question is that what is the difference between '&' and equal operator '=' ? I tested it with file... (6 Replies)
Discussion started by: segmentation
6 Replies

6. Shell Programming and Scripting

Problem with format numbers

Hello Everyone! I hope you can help me!! I have this little problem: I executed oracle query and the output of the result are in a text file called "DATAFILE.txt", and the value of file is: 97.37 Well, the script compare the result in text file with a condition: ... (5 Replies)
Discussion started by: bobbasystem
5 Replies

7. Shell Programming and Scripting

Problem with sub command (awk) and numbers

Hi, I am trying to perform a simple soustraction between two floating numbers and cannot get it done for some reason due to the use of the sub command. The following is the straight-forward result of the soustraction: $ echo | gawk '{a=968;b=967.99;c=a-b;print c}' ... (2 Replies)
Discussion started by: Indalecio
2 Replies

8. UNIX for Dummies Questions & Answers

Awk ranges for selecting numbers

Hi, I am trying to use AWK to do some editing and formating of large tables of numbers and I am having trouble getting it to work. For brevities sake, I won't show the whole table, but I have a sample set of code: und$ awk '{($2+0) > 50;print $1}' temp 2000 147 2008 128 2002 100 1999 47... (2 Replies)
Discussion started by: ikerrin1@gmail.
2 Replies

9. Shell Programming and Scripting

grep or awk problem, unable to extract numbers

Hi, I've trouble getting some numbers from a html-file. The thing is that I have several html-logs that contains lines like this: nerdnerd, how_old_r_u:45782<br>APPLY: <hour_second> Verification succeded This is some of what I've extracted from a html file but all I really want is the number... (7 Replies)
Discussion started by: baghera
7 Replies

10. Shell Programming and Scripting

problem with floating point numbers in awk

hi all, i have the following problem using awk in a script i want to read the values from a column with real numbers and calculate the mean.the problem is that when i use a statement such as this num = $4 i cant find a way to convert the variable from string to floating point to perform... (7 Replies)
Discussion started by: kanagias
7 Replies
Login or Register to Ask a Question