Bash - DoWhile - Read a File content
I need a huge favor from you.
I have to run several times a PHP script, but I have no knowledge of programming in bash.
The script开发者_如何学Go should work like this:
Within a cycle DoWhile ->
- Execute PHP script directory / crawler.php,
- I read the contents of the directory / array.txt
- If the content is equal to 0 then I get out of the loop (break;)
- If the content is different from 0 then the continuous cycle
The script directory / crawler.php must be tested at least once.
Some of you know how to write this code in Bash? Bash For those who know the code is really simple, but it is very difficult for me because I do not know anything Bash.
I just need this script in my "bash-programming-life. "
Thanks
Something like
php directory/crawler.php
while [[ "$(cat directory/array.txt)" -ne "0" ]]; do
php directory/crawler.php
done
presuming that the directory/array.txt file only contains a 0 when execution should terminate.
#!/bin/bash
file=directory/array.txt
>>"$file" # create the file if it doesn't exist
until [[ "$(<"$file")" == "0" ]]
do
php directory/crawler.php
done
精彩评论