About linux array definition, and generation methods, see: linux shell dynamically generated array series seq tips. My main point here is to efficiently generate list strings, as well as array methods.
First, the seq method generates:
[chengmo@centos5 shell]$ aNumList=$(seq 100);[chengmo@centos5 shell]$ echo $aNumList1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
aNumList gets a string, the difference is separated by: space. In Linux, you can think of it as a list. It can be read by the for…in loop.
[chengmo@centos5 shell]$ for i in $aNumList;do echo $i;done;1234……
if needed To generate an array, you only need to add $(seq 100) to "()”.
[chengmo@centos5 ~]$ aNumList=($(seq 100));[chengmo@centos5 ~]$ echo $aNumList1[chengmo@centos5 ~]$ echo ${#aNumList[@]}100
An array of length 100.
Second, generated by internal {begin..end}
This method is very convenient to generate seq. This is done by internal operators.
[chengmo@centos5 ~]$ echo {1..10}1 2 3 4 5 6 7 8 9 10
[chengmo@centos5 ~]$ for a in {1.. 10};do echo $a;done; 12345678910
Three, performance comparison
[chengmo@centos5 ~]$ time echo {1..100}1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
real 0m0.000suser 0m0.001ssys 0m0.000s
[chengmo@centos5 ~]$ time echo $(seq 100)1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
real 0m0.003suser 0m0.002ssys 0m0.001s
As you can see from above, {begin. The .end} speed is much faster than the seq call. It can be considered to be completed by internal operators when calling later.
You can try it, but dont do bad things. Fortunately, I need a password to modify m
A few days ago, a Linux system administrator asked the author for help. He said th
This tutorial gives examples of how to provide messages/dialogs in Bash Shell scripts using tools l
When reading apue, the shared storage area is not used for instance. For this reason, I wrote a smal
Linux environment variables (a)
Better wireless support Linux kernel upgrade 2.6.117
Network analysis example under Linux system
How to hide nginx and PHP version number
Detailed Explanation of 7 Weapons in Linux
Common command of vim in Linux
Firefox 3.6 RC1 released The official version will be launched next Monday
How to use BitTorrent to download in the Linux command line
What if Linux forgets the password?
Solutions to common problems in Linux systems
Implementation of Network Load Balancing for Windows 2003 System
Quickly view the installation time of win8.1 system
Win8 can not log in Skype prompt disk input and output error solution
Windows XP system shutdown and automatic restart solution
Win10 Tips: Have to tell you 10 tips on Win10
Win10 wireless network instability analysis and solutions
Win8 Encyclopedia 60: How to adjust the screen display ratio
Win7 system usb wireless network card driver how to install