实例介绍
Shell脚本高级编程教程,希望对你有所帮助。 Example 10-23. Using continue N in an actual task: 1 # Albert Reiner gives an example of how to use "continue N": 2 # --------------------------------------------------------- 3 4 # Suppose I have a large number of jobs that need to be run, with 5 #+ any data that is to be treated in files of a given name pattern in a 6 #+ directory. There are several machines that access this directory, and 7 #+ I want to distribute the work over these different boxen. Then I 8 #+ usually nohup something like the following on every box: 9 10 while true 11 do 12 for n in .iso.* 13 do 14 [ "$n" = ".iso.opts" ] && continue 15 beta=${n#.iso.} 16 [ -r .Iso.$beta ] && continue 17 [ -r .lock.$beta ] && sleep 10 && continue 18 lockfile -r0 .lock.$beta || continue 19 echo -n "$beta: " `date` 20 run-isotherm $beta 21 date 22 ls -alF .Iso.$beta 23 [ -r .Iso.$beta ] && rm -f .lock.$beta 24 continue 2 25 done 26 break 27 done 28 29 # The details, in particular the sleep N, are particular to my 30 #+ application, but the general pattern is: 31 32 while true 33 do 34 for job in {pattern} 35 do 36 {job already done or running} && continue 37 {mark job as running, do job, mark job as done} 38 continue 2 39 done 40 break # Or something like `sleep 600' to avoid termination. 41 done 42 43 # This way the script will stop only when there are no more jobs to do 44 #+ (including jobs that were added during runtime). Through the use 45 #+ of appropriate lockfiles it can be run on several machines 46 #+ concurrently without duplication of calculations [which run a couple 47 #+ of hours in my case, so I really want to avoid this]. Also, as search 48 #+ always starts again from the beginning, one can encode priorities in 49 #+ the file names. Of course, one could also do this without `continue
【实例截图】
【核心代码】
4744300845156857978.zip
└── shell高级编程实例
├── shell高级编程.pdf
└── shell高级编程源码
├── abs-book.sgml
├── add-drive.sh
├── agram2.sh
├── agram.sh
├── alias.sh
├── allprofs.sh
├── alt-bc.sh
├── am-i-root.sh
├── and-list2.sh
├── and-or.sh
├── archiveweblogs.sh
├── arglist.sh
├── arith-ops.sh
├── arith-tests.sh
├── array-append.bash
├── array-assign.bash
├── array-function.sh
├── array-ops.sh
├── array-strops.sh
├── arrow-detect.sh
├── ascii.sh
├── assert.sh
├── avoid-subshell.sh
├── background-loop.sh
├── bad-op.sh
├── badread.sh
├── base.sh
├── bashandperl.sh
├── bashpodder.sh
├── bashrc
├── basics-reviewed.bash
├── behead.sh
├── bin-grep.sh
├── blank-rename.sh
├── blot-out.sh
├── break-levels.sh
├── broken-link.sh
├── brownian.sh
├── bubble.sh
├── cannon.sh
├── case-cmd.sh
├── cdll
├── Change.log
├── collatz.sh
├── colm.sh
├── color-echo.sh
├── col-totaler2.sh
├── col-totaler3.sh
├── col-totaler.sh
├── commentblock.sh
├── connect-stat.sh
├── continue-n.example
├── continue-nlevel.sh
├── CopyArray.sh
├── copy-cd.sh
├── crypto-quote.sh
├── csubloop.sh
├── c-vars.sh
├── cvt.sh
├── data-file
├── date-calc.sh
├── days-between.sh
├── dd-keypress.sh
├── dereference.sh
├── de-rpm.sh
├── dev-tcp.sh
├── dialog.sh
├── dict-lookup.sh
├── directory-info.sh
├── Draw-box.sh
├── Du.sh
├── echo-params.sh
├── embedded-arrays.sh
├── empty-array.sh
├── encryptedpw.sh
├── erase.sh
├── escaped.sh
├── eval.example
├── ex10.sh
├── ex11.sh
├── ex12.sh
├── ex13.sh
├── ex14.sh
├── ex15.sh
├── ex16.sh
├── ex17.sh
├── ex18.sh
├── ex19.sh
├── ex1a.sh
├── ex1.sh
├── ex20.sh
├── ex21.sh
├── ex22a.sh
├── ex22.sh
├── ex23.sh
├── ex24.sh
├── ex25.sh
├── ex26a.sh
├── ex26.sh
├── ex27.sh
├── ex28.sh
├── ex29.sh
├── ex2.sh
├── ex30a.sh
├── ex30.sh
├── ex31.sh
├── ex32.sh
├── ex33a.sh
├── ex33.sh
├── ex34.sh
├── ex35.sh
├── ex36.sh
├── ex37.sh
├── ex38.sh
├── ex39.sh
├── ex3.sh
├── ex40.sh
├── ex41.sh
├── ex42.sh
├── ex43.sh
├── ex44.sh
├── ex45a.sh
├── ex45.sh
├── ex46.sh
├── ex47.sh
├── ex48.sh
├── ex49.sh
├── ex4.sh
├── ex50.sh
├── ex51.sh
├── ex52.sh
├── ex53.sh
├── ex54.sh
├── ex55.sh
├── ex56.sh
├── ex57.sh
├── ex58.sh
├── ex59.sh
├── ex5.sh
├── ex60.sh
├── ex61.sh
├── ex62.sh
├── ex63.sh
├── ex64.sh
├── ex65.sh
├── ex66.sh
├── ex67.sh
├── ex68a.sh
├── ex68.sh
├── ex69.sh
├── ex6.sh
├── ex70.sh
├── ex71a.sh
├── ex71b.sh
├── ex71c.sh
├── ex71.sh
├── ex72.sh
├── ex73.sh
├── ex74.sh
├── ex75.sh
├── ex76.sh
├── ex77.sh
├── ex78.sh
├── ex79.sh
├── ex7.sh
├── ex8.sh
├── ex9.sh
├── exercising-dd.sh
├── factr.sh
├── fc4upd.sh
├── fibo.sh
├── fifo.sh
├── file-comparison.sh
├── file-info.sh
├── file-integrity.sh
├── find-splitpara.sh
├── findstring.sh
├── for-loopcmd.sh
├── for-loopc.sh
├── from.sh
├── ftpget.sh
├── func-cmdlinearg.sh
├── gcd.sh
├── gen0
├── generate-script.sh
├── getopt-simple.sh
├── grp.sh
├── hanoi.bash
├── ha.sh
├── hash-example.sh
├── Hash.lib
├── hello.sh
├── here-function.sh
├── hexconvert.sh
├── homework.sh
├── horserace.sh
├── HTML
│ ├── aboutauthor.html
│ ├── aliases.html
│ ├── arithexp.html
│ ├── arrays.html
│ ├── asciitable.html
│ ├── assortedtips.html
│ ├── awk.html
│ ├── bash2.html
│ ├── bash-options.html
│ ├── bashver3.html
│ ├── biblio.html
│ ├── colorizing.html
│ ├── command-line-options.html
│ ├── commandsub.html
│ ├── common
│ │ ├── caution.png
│ │ ├── important.png
│ │ ├── logotp3.png
│ │ ├── note.png
│ │ ├── tip.png
│ │ └── warning.png
│ ├── communications.html
│ ├── comparison-ops.html
│ ├── contributed-scripts.html
│ ├── copyright.html
│ ├── credits.html
│ ├── dblparens.html
│ ├── debugging.html
│ ├── declareref.html
│ ├── devproc.html
│ ├── disclaimer.html
│ ├── dosbatch.html
│ ├── endnotes.html
│ ├── escapingsection.html
│ ├── exercises.html
│ ├── exitcodes.html
│ ├── exit-status.html
│ ├── external.html
│ ├── extmisc.html
│ ├── filearchiv.html
│ ├── files.html
│ ├── fto.html
│ ├── functions.html
│ ├── globbingref.html
│ ├── gotchas.html
│ ├── here-docs.html
│ ├── histcommands.html
│ ├── index.html
│ ├── internal.html
│ ├── io-redirection.html
│ ├── ioredirintro.html
│ ├── ivr.html
│ ├── list-cons.html
│ ├── localization.html
│ ├── localvar.html
│ ├── loopcontrol.html
│ ├── loops.html
│ ├── mathc.html
│ ├── mirrorsites.html
│ ├── miscellany.html
│ ├── moreadv.html
│ ├── nestedifthen.html
│ ├── nestedloops.html
│ ├── numerical-constants.html
│ ├── operations.html
│ ├── opprecedence.html
│ ├── optimizations.html
│ ├── options.html
│ ├── othertypesv.html
│ ├── parameter-substitution.html
│ ├── part1.html
│ ├── part2.html
│ ├── part3.html
│ ├── part4.html
│ ├── part5.html
│ ├── portabilityissues.html
│ ├── prelimexer.html
│ ├── process-sub.html
│ ├── procref1.html
│ ├── quoting.html
│ ├── randomvar.html
│ ├── recess-time.html
│ ├── recurnolocvar.html
│ ├── recursionsct.html
│ ├── redirapps.html
│ ├── redircb.html
│ ├── refcards.html
│ ├── regexp.html
│ ├── restricted-sh.html
│ ├── revisionhistory.html
│ ├── sample-bashrc.html
│ ├── scrstyle.html
│ ├── securityissues.html
│ ├── sedawk.html
│ ├── sha-bang.html
│ ├── special-chars.html
│ ├── string-manipulation.html
│ ├── subshells.html
│ ├── systemdirs.html
│ ├── system.html
│ ├── terminalccmds.html
│ ├── testbranch.html
│ ├── testsandcomparisons.html
│ ├── tests.html
│ ├── testtest.html
│ ├── textproc.html
│ ├── timedate.html
│ ├── todolist.html
│ ├── toolsused.html
│ ├── untyped.html
│ ├── varassignment.html
│ ├── variables2.html
│ ├── variables.html
│ ├── wherehelp.html
│ ├── why-shell.html
│ ├── winscript.html
│ ├── wrapper.html
│ ├── writingscripts.html
│ ├── xrefindex.html
│ └── zeros.html
├── hypotenuse.sh
├── idelete.sh
├── ifs-empty.sh
├── ifs.sh
├── incompat.sh
├── INDEX00.sgml
├── ind-func.sh
├── ind-ref.sh
├── insertion-sort.bash
├── int-or-string.sh
├── ip.sh
├── isalpha.sh
├── iscan.sh
├── is_spammer.bash
├── is-spammer.sh
├── keypress.sh
├── kill-byname.sh
├── kill-process.sh
├── length.sh
├── letter-count2.sh
├── letter-count.sh
├── life.sh
├── line-number.sh
├── list-glob.sh
├── logevents.sh
├── logging-wrapper.sh
├── lookup.sh
├── lowercase.sh
├── m4.sh
├── mailbox_grep.sh
├── mail-format.sh
├── makedict.sh
├── manview.sh
├── match-string.sh
├── max2.sh
├── max.sh
├── missing-keyword.sh
├── monthlypmt.sh
├── Moraes-COPYRIGHT
├── multiple-processes.sh
├── multiplication.sh
├── names.data
├── nested-loop.sh
├── nightly-backup.sh
├── numbers.sh
├── obj-oriented.sh
├── online.sh
├── opprec-table.sgml
├── pad.sh
├── paragraph-space.sh
├── param-sub.sh
├── patt-matching.sh
├── pb.sh
├── pick-card.sh
├── pid-identifier.sh
├── poem.sh
├── pr-asc.sh
├── prepend.sh
├── primes.sh
├── protect_literal.sh
├── pw.sh
├── q-function.sh
├── quote-fetch.sh
├── ra2ogg.sh
├── ramdisk.sh
├── random2.sh
├── random-between.sh
├── random-test.sh
├── rand-string.sh
├── README
├── read-novar.sh
├── readpipe.sh
├── read-redir.sh
├── read-r.sh
├── realname.sh
├── reassign-stdout.sh
├── recurse.sh
├── recursion-demo.sh
├── redir1.sh
├── redir2a.sh
├── redir2.sh
├── redir3.sh
├── redir4a.sh
├── redir4.sh
├── redir5.sh
├── ref-params.sh
├── remote.bash
├── reply.sh
├── resistor-inventory.sh
├── restricted.sh
├── return-test.sh
├── revposparams.sh
├── rfe.sh
├── rnd.sh
├── rn.sh
├── rot13a.sh
├── rot13.sh
├── rot14.sh
├── rpm-check.sh
├── script-array.sh
├── script-detector.sh
├── seconds.sh
├── secret-pw.sh
├── seeding-random.sh
├── self-copy.sh
├── self-destruct.sh
├── self-document.sh
├── self-exec.sh
├── self-mailer.sh
├── self-source.sh
├── setnew-passwd.sh
├── set-pos.sh
├── soundcard-on.sh
├── soundex.sh
├── spam-lookup.sh
├── spawn.sh
├── splitcopy.sh
├── stack.sh
├── string.sh
├── strip-comments.sh
├── str-test.sh
├── stupid-script-tricks.sh
├── subshell-pitfalls.sh
├── subshell.sh
├── substring-extraction.sh
├── sum-product.sh
├── symlinks2.sh
├── symlinks.sh
├── tempfile-name.sh
├── test-cgi.sh
├── timed-input.sh
├── timeout.sh
├── tohtml.sh
├── t-out.sh
├── tree2.sh
├── tree.sh
├── twodim.sh
├── unalias.sh
├── unit-conversion.sh
├── unprotect_literal.sh
├── unset.sh
├── upperconv.sh
├── usage-message.sh
├── usb.sh
├── userlist.sh
├── usrmnt.sh
├── var-match.sh
├── vartrace.sh
├── VIEWDATA.BAT
├── viewdata.sh
├── weirdvars.sh
├── wf2.sh
├── wf.sh
├── wgetter2.bash
├── what.sh
├── wh-loopc.sh
├── whx.sh
├── wipedir.sh
├── words.data
└── wstrings.sh
4 directories, 476 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论