To write a program that imports data in batches, learn to write shell scripts! Now learn to use!
============================================
1, the first simple for loop
#!/bin/bash
For I in 1 2 3 4;
Do
echo $i;
Done
2. Test for self-growing loops:
#!/bin/bash
for ((I=1; i<=5; i++)
Do
echo $i;
Done
If there is an error, no then skip:
Syntax Error:bad for loop variable
Reason: The code is not wrong for standard bash, because Ubuntu is doing the same with dash instead of the traditional bash in order to speed up the boot.
Workaround: Cancel Dash
Dpkg-reconfigure Dash
A bullet box appears, select No
Refer to the original details to resolve the error:
http://blog.csdn.net/yf210yf/article/details/9206185
3, Actual combat: Batch Import data
#!/bin/bash
for ((I=1; i<=1000; i++)
Do
Echo ' Curl http://localhost/test.php?page= $i & ';
Done
With echo you can see the output, and the output of "add-end-0" for my test.php program runs out once
Write a simple shell script-For loop-Resolve error Syntax Error:bad for loop variable