Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-08-2012
Registered User
 
Join Date: Dec 2011
Posts: 84
Thanks: 29
Thanked 0 Times in 0 Posts
create an array of numbers in awk

Hi !

I try to create an array of a large amount of numbers in increasing order from 1 to 10,000 (or even infinity).

Is there an easier way to do that than writing:

Code:
split("1,2,3,4,5,6,7,8,9,10,11,12,13,14,..............,10000",numbers,",")

Doing something like:

Code:
split([1-10000],numbers)

Thanks !
Sponsored Links
    #2  
Old 04-08-2012
agama agama is offline Forum Advisor  
Always Learning
 
Join Date: Jul 2010
Location: earth>US>UTC-5
Posts: 1,454
Thanks: 108
Thanked 498 Times in 477 Posts
I guess you have your reasons, but I don't see the point of an array of sequential numbers.


Code:
awk '
   BEGIN {
      for( i = 1; i <= 10000; i++ )
         numbers[i] = i;
   }

The Following User Says Thank You to agama For This Useful Post:
lucasvs (04-08-2012)
Sponsored Links
    #3  
Old 04-08-2012
Registered User
 
Join Date: Dec 2011
Posts: 84
Thanks: 29
Thanked 0 Times in 0 Posts
You're absolutely right !

Thanks agama
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
generate array of random numbers saboture88 Programming 2 02-06-2012 07:05 AM
Help with printing sorted array of numbers pawannoel UNIX for Dummies Questions & Answers 0 05-02-2011 10:21 AM
can array store float point numbers naree Solaris 1 03-05-2008 05:59 AM
i cannot assign float point numbers to an array in solaris naree Solaris 11 02-27-2008 03:06 AM
create array holding characters from sring then echo array. rorey_breaker Shell Programming and Scripting 5 09-28-2007 08:42 AM



All times are GMT -4. The time now is 12:04 AM.