<div class="rich_media_content js_underline_content
 " id="js_content"> <section data-mpa-powered-by="yiban.io" style="white-space: normal;text-align: center;"><br></section><section style='margin-bottom: 20px;white-space: normal;caret-color: rgb(62, 62, 62);font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;text-size-adjust: auto;color: rgb(62, 62, 62);font-size: 16px;letter-spacing: 1px;word-spacing: 1px;text-align: left;'><p id="_img_parent_tmp" style="text-align:center"><strong style='color: rgb(0, 0, 0);word-spacing: 0.1em;caret-color: rgb(51, 51, 51);font-family: -apple-system, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);font-size: 18px;outline: 0px;'><span style='outline: 0px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;'><strong style='font-family: -apple-system, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;letter-spacing: 0.544px;'><span style="letter-spacing: 1px;"><img src="https://img.php.cn/upload/article/001/275/013/5e9e2e09cb66ac70555a8b09900a7da1-0.png" alt="알아야 할 쉘 스크립트에 관한 13가지 기본 질문" ></span></strong></span></strong></p></section><ul class="list-paddingleft-1" mp-original-font-size="16" mp-original-line- style="max-width:90%" style='margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;visibility: visible;line-height: 25px;'> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">쉘에 관한 클래식 13가지 질문</p></li> <ul class="list-paddingleft-1" mp-original-font-size="16" mp-original-line-height="25" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;list-style-type: square;visibility: visible;line-height: 25px;"> <li style="outline: 0px;visibility: visible;line-height: 25px;"> <p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">1. 왜 쉘이라고 부르나요?</p> </li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">2. 쉘 프롬프트(PS1) 및 캐리지(CR)는 어떤 관계인가요? </p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">3. 다른 사람이 울릴 때 당신도 울릴 때 </p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">4. mark) 및 (작은따옴표) </p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"> <p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">5. var=value의 차이점은 무엇인가요? </p> </li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">6. exec와 소스의 차이점은 무엇인가요? </p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">7. ( )와 { }의 차이점은 무엇인가요? </p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">8. <span></span><span mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;cursor: pointer;visibility: visible;line-height: 25px;"><span data-formula="(()) 与 " data-formula-type="inline-equation" mp-original-font-size="16" mp-original-line-height="25" role="presentation" style="outline: 0px;visibility: visible;line-height: 25px;"><svg aria-hidden="true" focusable="false" mp-original-font-size="16" mp-original-line-height="25" role="img" style="vertical-align: -0.566ex;width: 6.259ex;height: 2.262ex;visibility: visible;line-height: 25px;" viewbox="0 -750 2766.3 1000" xmlns="http://www.w3.org/2000/svg"><g fill="currentColor" mp-original-font-size="16" mp-original-line-height="25" stroke="currentColor" stroke-width="0" style="visibility: visible;line-height: 25px;" transform="matrix(1 0 0 -1 0 0)">()과 ${}의 차이점은 무엇인가요? <g data-mml-node="math" mp-original-font-size="16" mp-original-line-height="25" style="visibility: visible;line-height: 25px;"></g></g></svg></span></span></p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">9. <span></span><span mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;cursor: pointer;visibility: visible;line-height: 25px;"><svg aria-hidden="true" focusable="false" mp-original-font-size="16" mp-original-line-height="25" role="img" style="vertical-align: -0.452ex;width: 4.499ex;height: 2.149ex;visibility: visible;line-height: 25px;" viewbox="0 -750 1988.3 950" xmlns="http://www.w3.org/2000/svg"><g fill="currentColor" mp-original-font-size="16" mp-original-line-height="25" stroke="currentColor" stroke-width="0" style="visibility: visible;line-height: 25px;" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="math" mp-original-font-size="16" mp-original-line-height="25" style="visibility: visible;line-height: 25px;"><g data-mjx-texclass="ORD" data-mml-node="TeXAtom" mp-original-font-size="16" mp-original-line-height="25" style="visibility: visible;line-height: 25px;"><g data-mml-node="mo" mp-original-font-size="16" mp-original-line-height="25" style="visibility: visible;line-height: 25px;"><path d="M56 347Q56 429 86 498T164 612T270 680T386 705Q522 705 622 603T722 349Q722 126 608 126Q541 126 513 176Q512 177 512 179T510 182L509 183Q508 183 503 177T487 163T464 146T429 132T385 126Q311 126 251 186T190 347Q190 448 251 508T385 568Q426 568 460 548T509 511T531 479H555Q580 479 582 478Q586 477 587 468Q588 454 588 338V260Q588 200 593 182T619 163Q641 163 655 178T674 223T680 273T682 325V330Q682 426 647 500Q611 569 544 618T388 668Q271 668 184 577T96 347Q96 216 180 121T396 26Q421 26 446 28T493 34T535 43T573 52T605 63T629 72T647 80T657 84H716Q722 78 722 74Q722 65 675 45T547 7T392 -11Q255 -11 156 90T56 347ZM274 347Q274 266 308 214T390 162Q420 162 449 182T498 235L504 245V449L498 459Q453 532 387 532Q347 532 311 483T274 347Z" data-c="40" mp-original-font-size="16" mp-original-line-height="25" style="visibility: visible;line-height: 25px;"></path></g></g></g></g></svg>과 </span>*의 차이점은 무엇인가요? </p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">10. &&와 ||의 차이점은 무엇인가요? </p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">11. >의 차이점은 무엇인가요? </p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">12. 이프나 케이스를 원하시나요? </p></li> <li style="outline: 0px;visibility: visible;line-height: 25px;"><p mp-original-font-size="16" mp-original-line-height="25" style="outline: 0px;visibility: visible;line-height: 25px;">13.for 무엇을 위해 그리고 언제까지의 차이점은 무엇인가요? </p></li> </ul> </ul> <h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style='margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;visibility: visible;line-height: 32px;'>1. 왜 쉘이라고 부르나요?</h3> <blockquote data-tool="mdnice编辑器" mp-original-font-size="14.399999618530273" mp-original-line-height="23" style='margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4);color: rgb(106, 115, 125);font-size: 14.4px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;overflow: auto;background-color: rgba(0, 0, 0, 0.047);visibility: visible;line-height: 23px;'><p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;font-size: 16px;color: black;line-height: 26px;visibility: visible;">컴퓨터의 동작은 하드웨어와 분리될 수 없다는 것을 알지만, 하드웨어 드라이버는 <code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;visibility: visible;line-height: 26px;'>操作系统</code>(<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;visibility: visible;line-height: 26px;'>OS</code>,<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;visibility: visible;line-height: 26px;'>Opertating System</code>)的软件来管控。<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;visibility: visible;line-height: 26px;'>linux</code>严格来说只是一个<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;visibility: visible;line-height: 26px;'>操作系统</code>(<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;visibility: visible;line-height: 26px;'>OS</code>),我们称之为<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;visibility: visible;line-height: 26px;'>内核</code>(<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;visibility: visible;line-height: 26px;'>kernel</code>라는 장치에 의해서만 직접 구동될 수 있습니다. ). </p></blockquote> <blockquote data-tool="mdnice编辑器" mp-original-font-size="14.399999618530273" mp-original-line-height="23" style='margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4);color: rgb(106, 115, 125);font-size: 14.4px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;overflow: auto;background-color: rgba(0, 0, 0, 0.047);line-height: 23px;'><p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;font-size: 16px;color: black;line-height: 26px;">사용자는 <code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>kernel</code>,而是通过<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>kernel</code>的外壳程序,也就是所谓的<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>shell</code>,来与<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>kernel</code>沟通。<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>shell</code>是一个使用者与系统的<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>交互界面(interface)</code>, 只能让使用者通过<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>命令行</code>(<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>command line</code>) 시스템을 사용하여 작업을 완료하기 위해 직접 조작할 수 있는 방법이 없습니다. 따라서 <br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;">shell의 가장 간단한 정의는 - 명령 해석기(Command Interpreter): </p></blockquote> <ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style='margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;'> <li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">사용자의 명령을 핵심 처리로 번역합니다. </section></li> <li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">동시에 핵심 처리 결과를 사용자에게 번역합니다. </section></li> </ul> <blockquote data-tool="mdnice编辑器" mp-original-font-size="14.399999618530273" mp-original-line-height="23" style='margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4);color: rgb(106, 115, 125);font-size: 14.4px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;overflow: auto;background-color: rgba(0, 0, 0, 0.047);line-height: 23px;'><p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;font-size: 16px;color: black;line-height: 26px;">다르다<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>OS</code>使用不同的<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>kernel</code>;<br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;">同一个<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>kernel</code>之上,也可以使用不同的<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>shell</code><br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;">常见的<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>shell</code>有<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>sh; bash; csh; ksh;</code>etc</p></blockquote> <h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style='margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;'>2. 쉘 프롬프트(PS1)와 캐리지 리턴(CR)은 어떤 관계가 있나요?</h3> <blockquote data-tool="mdnice编辑器" mp-original-font-size="14.399999618530273" mp-original-line-height="23" style='margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4);color: rgb(106, 115, 125);font-size: 14.4px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;overflow: auto;background-color: rgba(0, 0, 0, 0.047);line-height: 23px;'><p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;font-size: 16px;color: black;line-height: 26px;">쉘 터미널에 성공적으로 로그인하면 커서<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>cursor</code>左边部分,称之为提示符<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>prompt</code><br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;">通常一般用户使用<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>$</code>,管理员用户<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>root</code>使用<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>#</code></p></blockquote> <ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style='margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;'> <li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">쉘 프롬프트: 명령을 입력할 수 있습니다<br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;">명령을 입력한 후 <code mp-original-font-size="14" mp-original-line-height="26" style="margin-right : 2px; 여백 왼쪽: 2px; 패딩: 2px 4px; 윤곽선: 0px; 글꼴 크기: 14px; 테두리 반경: 4px; 색상: rgb(30, 107, 184); 배경색: rgba(27, 31 , 35, 0.047);font-family: " operator mono consolas monaco menlo monospace break-all>CR(캐리지 리턴)</code>최대 문자</section></li> <code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>CR(Carriage Return)</code>字符为止<li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">Carriage Return:可以执行命令了</section></li> </ul> <blockquote data-tool="mdnice编辑器" mp-original-font-size="14.399999618530273" mp-original-line-height="23" style='margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4);color: rgb(106, 115, 125);font-size: 14.4px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;overflow: auto;background-color: rgba(0, 0, 0, 0.047);line-height: 23px;'><p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;font-size: 16px;color: black;line-height: 26px;">若从技术的细节来看,shell会依据IFS(Internal Field Seperator) 将command line所输入的文字拆解为"字段"(word/field)。然后再针对特殊字符(meta)先作处理,最后重组整行command line。</p></blockquote> <h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style='margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;'>3. 别人echo, 你也echo, 是问echo知多少?</h3> <blockquote data-tool="mdnice编辑器" mp-original-font-size="14.399999618530273" mp-original-line-height="23" style='margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4);color: rgb(106, 115, 125);font-size: 14.4px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;overflow: auto;background-color: rgba(0, 0, 0, 0.047);line-height: 23px;'> <p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;font-size: 16px;color: black;line-height: 26px;"><code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>echo</code>将<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>argument</code>送到<code mp-original-font-size="14" mp-original-line-height="26" style='margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;'>标准输出(stdout)</code></p>캐리지 리턴: 명령을 실행할 수 있습니다<blockquote data-tool="mdnice editor" mp-original-font-size=" 14.399999618530273" mp-original-line-height="23" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0 , 0 , 0.4);색상: rgb(106, 115, 125);글꼴 크기: 14.4px;글꼴 계열: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, " pingfang sc cambria cochin georgia times new roman serif left normal auto background-color: rgba> <p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline : 0px ;font-size: 16px;color: black;line-height: 26px;">기술적인 세부 사항을 살펴보면 쉘은 명령줄에 입력된 텍스트를 "필드"(단어/필드)로 분해합니다. 그런 다음 특수 문자(메타)가 먼저 처리되고 마지막으로 전체 명령줄이 재구성됩니다. 🎜🎜</p> <h3 data-tool="mdnice editor" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px; 개요 : 0px; 글꼴 무게: 굵게; 글꼴 크기: 20px; 캐럿 색상: rgb(0, 0, 0); 색상: rgb(0, 0, 0); 글꼴 계열: Optima-Regular, Optima, PingFangSC -light, PingFangTC-light, " pingfang sc cambria cochin georgia times new roman serif left normal auto height:>3. 다른 사람이 에코하면 당신도 에코하는데 에코에 대해 얼마나 알고 있는지 묻고 있나요?</h3> <blockquote data-tool="mdnice editor" mp-original-font-size="14.399999618530273 " mp-origin-line-height="23" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4 );색상: rgb(106, 115, 125);글꼴 크기: 14.4px;글꼴 계열: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, " pingfang sc cambria cochin georgia times new roman serif left normal auto background-color: rgba height:><p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;개요: 0px;font -size: 16px;color: 검정;line-height: 26px;"><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right : 2px; 왼쪽 여백: 2px; 패딩: 2px 4px; 윤곽선: 0px; 글꼴 크기: 14px; 테두리 반경: 4px; 색상: rgb(30, 107, 184); 배경색: rgba(27, 31 , 35, 0.047);font-family: " operator mono consolas monaco menlo monospace break-all>echo</code>는 <code mp-original size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border -반경: 4px;색상: rgb(30, 107, 184);배경색: rgba(27, 31, 35, 0.047);글꼴 계열: " operator mono consolas monaco menlo break: break>인수</code>를 <code mp-original-font-size="14" mp-original-line-height="26" style="margin-right로 : 2px ; 여백 왼쪽: 2px; 패딩: 2px 4px; 윤곽선: 0px; 글꼴 크기: 14px; 테두리 반경: 4px; 색상: rgb(30, 107, 184); 배경색: rgba(27, 31 , 35 , 0.047);font-family: " operator mono consolas monaco menlo monospace break-all>표준 출력(stdout)</code>, 일반적으로 화면에 표시됨 🎜入Stdin 표준 입력 inStdout 표준 출력 </p></blockquote> <ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style='margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;'> <li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">Stderr 표준 오류 출력 </section></li> <li style="outline: 0px;line-height: 25px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;">echo -n # 取消换行符 echo -e # 启用反斜杠转译</pre><div class="contentsignin">로그인 후 복사</div></div>e<section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">4 :<code mp-original-font-size="14" mp-original-line-height="26" style=" 여백 오른쪽: 2px; 여백 왼쪽: 2px; 패딩: 2px 4px; 윤곽선: 0px; 글꼴 크기: 14px; 테두리 반경: 4px; 색상: rgb(30, 107, 184); 배경색: rgba( 27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">''</code>(단일 quote), 모든 인용문을 닫습니다</section></li><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">소프트 인용문:<code mp-original-font-size ="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;패딩: 2px 4px;개요: 0px;글꼴 크기: 14px;테두리 반경: 4px;색상: rgb(30, 107, 184);배경색: rgba(27, 31, 35, 0.047);글꼴 -family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">""</code>(큰따옴표), 예약됨<code mp-original- 글꼴 크기="14" mp-original-line-height="26" style="margin -right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border- 반경: 4px;색상: rgb(30, 107, 184);배경색: rgba(27, 31, 35, 0.047);글꼴 계열: "Operator Mono", Consolas, Monaco, Menlo, 고정폭;단어 나누기 : break-all;line-height: 26px;">$</code>Quote</section></li></ul> <h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;">5.var=value 내보내기와 내보내기의 차이점은 무엇인가요?</h3><blockquote data-tool="mdnice编辑器" mp-original-font-size="14.399999618530273" mp-original-line-height="23" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4);color: rgb(106, 115, 125);font-size: 14.4px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;overflow: auto;background-color: rgba(0, 0, 0, 0.047);line-height: 23px;"><p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;font-size: 16px;color: black;line-height: 26px;">变量定义:<code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">name=value</code>,等号左右两边不能使用分隔符。<br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;"/>变量替换:<code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">echo ${name}</code><br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;"/>export变量:<code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">export name=value</code>,使变量成为环境变量</p></blockquote><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;"># 本地变量 A=B # 取消变量 unset A # 环境变量 export A=B</pre><div class="contentsignin">로그인 후 복사</div></div><h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;">6. exec跟source差在哪?</h3><blockquote data-tool="mdnice编辑器" mp-original-font-size="14.399999618530273" mp-original-line-height="23" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4);color: rgb(106, 115, 125);font-size: 14.4px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;overflow: auto;background-color: rgba(0, 0, 0, 0.047);line-height: 23px;"><p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;font-size: 16px;color: black;line-height: 26px;">环境变量只能从父进程到子进程单向传递。换句话说:在子进程中环境如何变更,均不会影响父进程的环境。<br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;"/>当我们执行一个shell script时,其实是先产生一个sub-shell的子进程, 然后sub-shell再去产生命令行的子进程。另外,搜索公众号Linux就该这样学后台回复“git书籍”,获取一份惊喜礼包。</p></blockquote><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;"># 创建子shell执行脚本 ./sh # 当前shell执行 source sh # 当前shell执行后退出 exec sh</pre><div class="contentsignin">로그인 후 복사</div></div><h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;">7. ( ) 与 { } 差在哪?</h3><p data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 26px;"><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">( )</code><span> </span>将<code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">command group</code>置于<code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">sub-shell</code>执行<br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;"/><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">{ }</code><span> </span>则是在同一个<code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">shell</code>内完成</p><h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;">8.<span></span><span mp-original-font-size="20" mp-original-line-height="32" style="outline: 0px;cursor: pointer;line-height: 32px;"><span data-formula="(()) 与 " data-formula-type="inline-equation" mp-original-font-size="20" mp-original-line-height="32" role="presentation" style="outline: 0px;line-height: 32px;"><svg aria-hidden="true" focusable="false" mp-original-font-size="20" mp-original-line-height="32" role="img" style="vertical-align: -0.566ex;width: 6.259ex;height: 2.262ex;line-height: 32px;" viewbox="0 -750 2766.3 1000" xmlns="http://www.w3.org/2000/svg"><g fill="currentColor" mp-original-font-size="20" mp-original-line-height="32" stroke="currentColor" stroke-width="0" style="line-height: 32px;" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="math" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"><g data-mml-node="mo" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"><path d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z" data-c="28" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"></path></g><g data-mml-node="mo" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;" transform="translate(389, 0)"><path d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z" data-c="28" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"></path></g><g data-mml-node="mo" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;" transform="translate(778, 0)"><path d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z" data-c="29" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"></path></g><g data-mml-node="mo" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;" transform="translate(1167, 0)"><path d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z" data-c="29" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"></path></g><g data-mml-node="mo" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;" transform="translate(1833.8, 0)"><text data-variant="normal" font-family="serif" font-size="933.8px" mp-original-font-size="933.7999877929688" mp-original-line-height="1494" style="font-size: 933.7999877929688px;line-height: 1494px;" transform="matrix(1 0 0 -1 0 0)">과 함께 </text></g></g> </g></svg></span></span>()과 ${}의 차이점은 무엇인가요? </h3><ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);"><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">$()</code> 및 ``(백틱)은 모두 명령 대체에 사용됩니다.</section></li><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);"><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">${var}</code>与<span> </span><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">$var</code><span></span>은 모두 변수 대체에 사용됩니다.</section></li></ul><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;"># 假设我们定义了一个变量为: file=/dir1/dir2/dir3/my.file.txt # 我们可以用 ${ } 分别替换获得不同的值: # shell字符串的非贪婪(最小匹配)左删除 ${file#*/} # 拿掉第一条 / 及其左边的字符串:dir1/dir2/dir3/my.file.txt ${file#*.} #拿掉第一个 . 及其左边的字符串:file.txt # shell字符串的贪婪(最大匹配)左删除 ${file##*/} # 拿掉最后一条 / 及其左边的字符串:my.file.txt ${file##*.} # 拿掉最后一个 . 及其左边的字符串:txt # shell字符串的非贪婪(最小匹配)右删除: ${file%/*} # 拿掉最后条 / 及其右边的字符串:/dir1/dir2/dir3 ${file%.*} # 拿掉最后一个 . 及其右边的字符串:/dir1/dir2/dir3/my.file # shell字符串的贪婪(最大匹配)右删除: ${file%%/*} # 拿掉第一条 / 及其右边的字符串:(空值) ${file%%.*} # 拿掉第一个 . 及其右边的字符串:/dir1/dir2/dir3/my 记忆的方法为: # 是去掉左边(在键盘上 # 在 $ 之左边) % 是去掉右边(在键盘上 % 在 $ 之右边) 单一符号是最小匹配﹔两个符号是最大匹配。</pre><div class="contentsignin">로그인 후 복사</div></div><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;"># shell字符串取子串: ${file:0:5}:提取最左边的 5 个字节:/dir1 ${file:5:5}:提取第 5 个字节右边的连续 5 个字节:/dir2 # shell字符串变量值的替换: ${file/dir/path}:将第一个 dir 提换为 path:/path1/dir2/dir3/my.file.txt ${file//dir/path}:将全部 dir 提换为 path:/path1/path2/path3/my.file.txt # ${}还可针对变量的不同状态(没设定、空值、非空值)进行赋值: ${file-my.file.txt} :假如 $file 没有设定,则使用 my.file.txt 作传回值。(空值及非空值时不作处理) ${file:-my.file.txt} :假如 $file 没有设定或为空值,则使用 my.file.txt 作传回值。 (非空值时不作处理) ${file+my.file.txt} :假如 $file 设为空值或非空值,均使用 my.file.txt 作传回值。(没设定时不作处理) ${file:+my.file.txt} :若 $file 为非空值,则使用 my.file.txt 作传回值。 (没设定及空值时不作处理) ${file=my.file.txt} :若 $file 没设定,则使用 my.file.txt 作传回值,同时将 $file 赋值为 my.file.txt 。 (空值及非空值时不作处理) ${file:=my.file.txt} :若 $file 没设定或为空值,则使用 my.file.txt 作传回值,同时将 $file 赋值为 my.file.txt 。 (非空值时不作处理) ${file?my.file.txt} :若 $file 没设定,则将 my.file.txt 输出至 STDERR。 (空值及非空值时不作处理) ${file:?my.file.txt} :若 $file 没设定或为空值,则将 my.file.txt 输出至 STDERR。 (非空值时不作处理) tips: 以上的理解在于, 你一定要分清楚 unset 与 null 及 non-null 这三种赋值状态. 一般而言, : 与 null 有关, 若不带 : 的话, null 不受影响, 若带 : 则连 null 也受影响.</pre><div class="contentsignin">로그인 후 복사</div></div><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;"># 计算shell字符串变量的长度:${#var} ${#var} 可计算出变量值的长度: ${#file} 可得到 27 ,因为 /dir1/dir2/dir3/my.file.txt 刚好是 27 个字节... # bash数组(array)的处理方法 数组: A=(a b c d) 引用数组: ${A[@]} ${A[*]} 访问数组成员 ${A[0]} 计算数组长度 ${#A[@]} ${#A[*]} 数组重新赋值 A[2]=xyz # $(( ))是用来做整数运算的 a=5;b=7;c=2; echo $(( a + b * c))</pre><div class="contentsignin">로그인 후 복사</div></div><h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;">9.<span> </span><span mp-original-font-size="20" mp-original-line-height="32" style="outline: 0px;cursor: pointer;line-height: 32px;"><svg aria-hidden="true" focusable="false" mp-original-font-size="20" mp-original-line-height="32" role="img" style="vertical-align: -0.452ex;width: 4.499ex;height: 2.149ex;line-height: 32px;" viewbox="0 -750 1988.3 950" xmlns="http://www.w3.org/2000/svg"><g fill="currentColor" mp-original-font-size="20" mp-original-line-height="32" stroke="currentColor" stroke-width="0" style="line-height: 32px;" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="math" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"><g data-mjx-texclass="ORD" data-mml-node="TeXAtom" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"><g data-mml-node="mo" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"><path d="M56 347Q56 429 86 498T164 612T270 680T386 705Q522 705 622 603T722 349Q722 126 608 126Q541 126 513 176Q512 177 512 179T510 182L509 183Q508 183 503 177T487 163T464 146T429 132T385 126Q311 126 251 186T190 347Q190 448 251 508T385 568Q426 568 460 548T509 511T531 479H555Q580 479 582 478Q586 477 587 468Q588 454 588 338V260Q588 200 593 182T619 163Q641 163 655 178T674 223T680 273T682 325V330Q682 426 647 500Q611 569 544 618T388 668Q271 668 184 577T96 347Q96 216 180 121T396 26Q421 26 446 28T493 34T535 43T573 52T605 63T629 72T647 80T657 84H716Q722 78 722 74Q722 65 675 45T547 7T392 -11Q255 -11 156 90T56 347ZM274 347Q274 266 308 214T390 162Q420 162 449 182T498 235L504 245V449L498 459Q453 532 387 532Q347 532 311 483T274 347Z" data-c="40" mp-original-font-size="20" mp-original-line-height="32" style="line-height: 32px;"></path></g></g></g></g></svg>与</span>* 区别在哪?</h3><ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);"><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">"$@"</code><span> </span>则可得到 "p1" "p2 p3" "p4" 这三个不同的词段</section></li><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);"><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">"$*"</code><span> </span>则可得到 "p1 p2 p3 p4" 这一整串单一的词段</section></li></ul><h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;">10. && 与 || 差在哪?</h3><ol class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">테스트 명령에는 두 가지 형식이 있습니다.</section></li></ol><ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">테스트 표현식</section></li><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">[ 표현식 ]</section></li></ul><ol class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" start="2" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">bash의 테스트는 현재 세 가지 테스트 개체를 지원합니다</section></li></ol><ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"> <section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">문자열: 문자열 </section></li><li style="outline: 0px;line-height: 25px;"> <section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">integer: 정수 </section></li><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">file: file </section></li></ul><ol class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" start="3" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">은 표현식이 true인 경우 0(true)을 반환하고, 그렇지 않으면 0이 아닌(false)을 반환합니다</section></li></ol><ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);"><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;개요: 0px;글꼴 크기: 14px;테두리 반경: 4px;색상: rgb(30, 107, 184);배경색: rgba(27, 31, 35, 0.047);글꼴 계열: "Operator Mono", Consolas , Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">command1 && command2</code><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">command1 && command2</code><span> </span># command2只有在command1的RV为0(true)的条件下执行。<a data-itemshowtype="0" data-linktype="2" href="https://www.php.cn/link/725215ed82ab6306919b485b81ff9615" imgdata="null" imgurl="" linktype="text" style="font-family: -apple-system-font, "system-ui", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;letter-spacing: 1px;text-align: left;white-space: normal;word-spacing: 1px;caret-color: rgb(62, 62, 62);" tab="innerlink" target="_blank" textvalue="关注Linux中文社区"><span style="outline: 0px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">关注Linux中文社区</span></a></section></li><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);"><code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">command1 || command2</code> <span># command2只有재command1的RV为0(true)的条件下执行。< a data-itemshowtype="0" data-linktype="2" href="https://www.php.cn/link/725215ed82ab6306919b485b81ff9615" imgdata="null" imgurl="" linktype="text" style="font -family: -apple-system-font, "system-ui", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font -size: 16px;letter-spacing: 1px;text-align: left;white-space: Normal;word-spacing: 1px;caret-color: rgb(62, 62, 62);" tab="innerlink" target="_blank" textvalue="关注Linux中文社区"><span style="outline: 0px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">关注Linux中文社区</span></a></section></li>🎜🎜< 코드 mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size : 14px;경계 반경: 4px;색상: rgb(30, 107, 184);배경색: rgba(27, 31, 35, 0.047);글꼴 계열: "Operator Mono", Consolas, Monaco, Menlo, 고정 폭;단어 나누기: 나누기-모두;줄 높이: 26px;">command1 || command2</code>🎜 🎜# command2에는 command1의 RV가 비0(false)의 条件下执行이 있습니다.</section></li></ul><ol class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" start="4" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">先替换变量再比较</section></li></ol><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;">A=123 [ -n "$A" ] && ([ "$A" -lt 100 ] || echo "too big") unset A</pre><div class="contentsignin">로그인 후 복사</div></div><h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;">11. > 与 < 差在哪?</h3><ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style="margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;"><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">0: Standard Input (STDIN)</section></li><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">1: Standard Output (STDOUT)</section></li><li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">2: Standard Error Output (STDERR)</section></li></ul><blockquote data-tool="mdnice编辑器" mp-original-font-size="14.399999618530273" mp-original-line-height="23" style="margin-top: 20px;margin-bottom: 20px;padding: 10px 10px 10px 20px;outline: 0px;border-left-color: rgba(0, 0, 0, 0.4);color: rgb(106, 115, 125);font-size: 14.4px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;overflow: auto;background-color: rgba(0, 0, 0, 0.047);line-height: 23px;"><p mp-original-font-size="16" mp-original-line-height="26" style="padding-top: 8px;padding-bottom: 8px;outline: 0px;font-size: 16px;color: black;line-height: 26px;">我们可用 < 来改变读进的数据信道(stdin),使之从指定的档案读进。<br mp-original-font-size="16" mp-original-line-height="26" style="outline: 0px;line-height: 26px;"/>我们可用<code mp-original-font-size="14" mp-original-line-height="26" style="margin-right: 2px;margin-left: 2px;padding: 2px 4px;outline: 0px;font-size: 14px;border-radius: 4px;color: rgb(30, 107, 184);background-color: rgba(27, 31, 35, 0.047);font-family: "Operator Mono", Consolas, Monaco, Menlo, monospace;word-break: break-all;line-height: 26px;">></code><span> </span>来改变送出的数据信道(stdout, stderr),使之输出到指定的档案。</p></blockquote><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;">ls my.file no.such.file 1> file.out 2>file.err # 2>&1 就是将stderr并进stdout做输出 ls my.file no.such.file 1> file.out 2>&1 # /dev/null 空 ls my.file no.such.file >/dev/null 2>&1 cat < file > file # 在 IO Redirection 中,stdout 与 stderr 的管道会先准备好,才会从 stdin 读进资料。 # 也就是说,在上例中,> file 会先将 file 清空,然后才读进 < file , # 但这时候档案已经被清空了,因此就变成读不进任何数据了</pre><div class="contentsignin">로그인 후 복사</div></div><h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;">12. 你要if还是case呢?</h3><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;"># if echo -n "Do you want to continue?(Yes/No):" read YN if [ "$YN"=Y -o "$YN"=y -o "$YN"="Yes" -o "$YN"="yes" -o "$YN"="YES"];then echo "continue" else exit 0 fi # case echo -n "Do you want to continue?(Yes/No):" read YN case "$YN" in [Yy]|[Yy][Ee][Ss]) echo "continue" ;; *) exit 0 esac</pre><div class="contentsignin">로그인 후 복사</div></div><h3 data-tool="mdnice编辑器" mp-original-font-size="20" mp-original-line-height="32" style="margin-top: 30px;margin-bottom: 15px;outline: 0px;font-weight: bold;font-size: 20px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 32px;">13. for what? while与until差在哪?</h3><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false;"># for for ((i=1;i<=10;i++)) do echo "num is $i" done # while num=1 while [ "$num" -le 10 ]; do echo "num is $num" num=$(($num + 1)) done # until num=1 until [ "$num" -gt 10 ]; do echo "num is $num" num=$(($nu + 1)) done</pre><div class="contentsignin">로그인 후 복사</div></div><ul class="list-paddingleft-1" data-tool="mdnice编辑器" mp-original-font-size="16" mp-original-line-height="25" style='margin-top: 8px;margin-bottom: 8px;padding-left: 25px;outline: 0px;caret-color: rgb(0, 0, 0);color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;font-size: 16px;text-align: left;white-space: normal;text-size-adjust: auto;line-height: 25px;'> <li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">break 是结束 loop</section></li> <li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">return 是结束 function</section></li> <li style="outline: 0px;line-height: 25px;"><section mp-original-font-size="16" mp-original-line-height="26" style="margin-top: 5px;margin-bottom: 5px;outline: 0px;line-height: 26px;color: rgb(1, 1, 1);">exit 是结束 script/shell</section></li> </ul> </li> </ul> </blockquote> </blockquote> </div>