Miserlou/Loop hiện có 695 sao trên GitHub, viết chủ yếu bằng Rust. UNIX's missing `loop` command
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Loops can be set to timers which accept humanized times from the microsecond to the year with --every:
$ loop --every 5s -- date
Thu May 17 10:51:03 EDT 2018
Thu May 17 10:51:08 EDT 2018
Thu May 17 10:51:13 EDT 2018
Looping can be limited to a set duration with --for-duration:
$ loop --for-duration 8s --every 2s -- date
Fri May 25 16:46:42 EDT 2018
Fri May 25 16:46:44 EDT 2018
Fri May 25 16:46:46 EDT 2018
Fri May 25 16:46:48 EDT 2018
$
Or until a certain date/time with --until-time:
$ loop --until-time '2018-05-25 20:50:00' --every 5s -- 'date -u'
Fri May 25 20:49:49 UTC 2018
Fri May 25 20:49:54 UTC 2018
Fri May 25 20:49:59 UTC 2018
$
Until Conditions
loop can iterate until output contains a string with --until-contains:
loop can iterate until the output stays the same with --until-same. This would be useful, for instance,
for monitoring with du until a download or copy finishes:
If you have a lot of files and a program, but don't know which file is the one the program takes, you can loop over them until you find it:
$ ls -1 | loop --until-success -- './my_program $ITEM';
Or, if you have a list of files but need to find the one which causes your program to fail:
$ ls -1 | loop --until-fail -- './my_program $ITEM';
Waiting for a website to appear online
If you've just kicked off a website deployment pipeline, you might want to run a process when the site starts returning 200 response codes. With --every and --until-contains, you can do this without flooding the site with requests:
If you've got a whole list of files that you want to create backup copies of, you can do it like so:
$ ls
hello.jpg
$ ls -1 | loop -- 'cp $ITEM $ITEM.bak'
$ ls
hello.jpg
hello.jpg.bak
Keep trying a failing script until it passes, up to 5 times
This is an example from StackExchange.
I want to write logic in shell script which will retry it to run again after 15 sec upto 5 times based on "status code=FAIL" if it fails due to some issue.
There are so many questions like this on StackExchange, which all end up with long threads of complicated answers.
Which will do the thing every 15 seconds until it succeeds, for a maximum of five times.
Keep trying a failing script until timeout
If dealing with a command or script that occasionally fails in a CI environment, you may want to try for a given amount of time before giving up and failing the build.
Which will do the thing every 5 seconds until it succeeds or until the duration is met. If the duration is met, it will give the same non-zero return as the timeout command 124.
Comparison with GNU Parallel
This thread on Reddit with GNU Parallel author Ole Tange has some interesting side-by-side comparisons between loop and parallel.
More examples
Got any more useful examples? Send a pull request!
Contributing
This project is still young, so there is still plenty to be done. Contributions are more than welcome!
Please file tickets for discussion before submitting patches. Pull requests should target master and should leave Loop in a "shippable" state if merged.
If you are adding a non-trivial amount of new code, please include a functioning test in your PR. The test suite will be run by Travis CI once you open a pull request. Please include the GitHub issue or pull request URL that has discussion related to your changes as a comment in the code (example). This greatly helps for project maintainability, as it allows us to trace back use cases and explain decision making. Similarly, please make sure that you meet all of the requirements listed in the pull request template.
Please feel free to work on any open ticket, especially any ticket marked with the "help-wanted" label!
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/Miserlou/Loop là nguồn chính thức.
Miserlou/Loop có phải mã nguồn mở không?
Có — Miserlou/Loop phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/Miserlou/Loop.
Miserlou/Loop có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho Miserlou/Loop. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
Miserlou/Loop có trang demo không?
Dự án có trang chủ ở https://github.com/Miserlou/Loop. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
Miserlou/Loop còn đang phát triển không?
Commit gần nhất trên Miserlou/Loop là 4.1 năm trước (theo timestamp GitHub). Repo có 28 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
Miserlou/Loop dùng license gì?
Miserlou/Loop phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về Loop?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về Loop.