1 Star 0 Fork 0

Kaelinda/kaelindaTop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
shell.html 21.30 KB
一键复制 编辑 原始数据 按行查看 历史
zuosong 提交于 2019-03-12 15:13 . 2019-03-12 15:13:57
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>
shell - kaelinda
</title>
<link href="atom.xml" rel="alternate" title="kaelinda" type="application/atom+xml">
<link rel="stylesheet" href="asset/css/foundation.min.css" />
<link rel="stylesheet" href="asset/css/docs.css" />
<script src="asset/js/vendor/modernizr.js"></script>
<script src="asset/js/vendor/jquery.js"></script>
<script src="asset/highlightjs/highlight.pack.js"></script>
<link href="asset/highlightjs/styles/github.css" media="screen, projection" rel="stylesheet" type="text/css">
<script>hljs.initHighlightingOnLoad();</script>
<script type="text/javascript">
function before_search(){
var searchVal = 'site:kaelinda.top ' + document.getElementById('search_input').value;
document.getElementById('search_q').value = searchVal;
return true;
}
</script>
</head>
<body class="antialiased hide-extras">
<div class="marketing off-canvas-wrap" data-offcanvas>
<div class="inner-wrap">
<nav class="top-bar docs-bar hide-for-small" data-topbar>
<section class="top-bar-section">
<div class="row">
<div style="position: relative;width:100%;"><div style="position: absolute; width:100%;">
<ul id="main-menu" class="left">
<li id=""><a target="_self" href="index.html">最近更新</a></li>
<li id=""><a target="_self" href="archives.html">归档目录</a></li>
<li id="ios.css"><a target="_self" href="ios.html">iOS</a></li>
<li id="swift.css"><a target="_self" href="swift.html">Swift</a></li>
<li id="reactnative.css"><a target="_self" href="reactnative.html">RN</a></li>
<li id="js.css"><a target="_self" href="js.html">JS</a></li>
<li id="shell.css"><a target="_self" href="shell.html">shell</a></li>
<li id="coding.css"><a target="_self" href="coding.html">编程</a></li>
<li id="live.css"><a target="_self" href="live.html">随笔</a></li>
<li id="app.css"><a target="_blank" href="app.html">APP推荐</a></li>
</ul>
<ul class="right" id="search-wrap">
<li>
<form target="_blank" onsubmit="return before_search();" action="http://google.com/search" method="get">
<input type="hidden" id="search_q" name="q" value="" />
<input tabindex="1" type="search" id="search_input" placeholder="Search"/>
</form>
</li>
</ul>
</div></div>
</div>
</section>
</nav>
<nav class="tab-bar show-for-small">
<a href="javascript:void(0)" class="left-off-canvas-toggle menu-icon">
<span> &nbsp; kaelinda</span>
</a>
</nav>
<aside class="left-off-canvas-menu">
<ul class="off-canvas-list">
<li><a target="_self" href="index.html">最近更新</a></li>
<li><a target="_self" href="archives.html">归档目录</a></li>
<li><a target="_self" href="ios.html">iOS</a></li>
<li><a target="_self" href="swift.html">Swift</a></li>
<li><a target="_self" href="reactnative.html">RN</a></li>
<li><a target="_self" href="js.html">JS</a></li>
<li><a target="_self" href="shell.html">shell</a></li>
<li><a target="_self" href="coding.html">编程</a></li>
<li><a target="_self" href="live.html">随笔</a></li>
<li><a target="_blank" href="app.html">APP推荐</a></li>
<li><label>Categories</label></li>
<li><a href="reactnative.html">React-Native</a></li>
<li><a href="ios.html">iOS</a></li>
<li><a href="app.html">MacAPP</a></li>
<li><a href="swift.html">Swift</a></li>
<li><a href="js.html">JavaScript</a></li>
<li><a href="vue.html">Vue</a></li>
<li><a href="shell.html">shell</a></li>
<li><a href="%E7%BD%91%E7%BB%9C.html">网络</a></li>
</ul>
</aside>
<a class="exit-off-canvas" href="#"></a>
<section id="main-content" role="main" class="scroll-container">
<script type="text/javascript">
$(function(){
$('#menu_item_index').addClass('is_active');
});
</script>
<div class="row">
<div class="large-8 medium-8 columns">
<div class="markdown-body home-categories">
<div class="article">
<a class="clearlink" href="15232599795686.html">
<h1>每天学习一个shell技能(8)</h1>
<div class="a-content">
<div class="a-content-text">
<h2 id="toc_0">shell 终端打印</h2>
<pre><code class="language-text">```
printf &quot;%-5s %-10s %-4s \n&quot; NO Name Mark
printf &quot;%-5s %-10s %-4s \n&quot; 1 kael 100
printf &quot;%-5s %-10s %-4s \n&quot; 2 linda 99
printf &quot;%-5s %-10s %-4s \n&quot; 3 rouse 98
// 打印结果
NO Name Mark
1 kael 100
2 linda 99
3 rouse 98
```
</code></pre>
<blockquote>
<p>printf 行尾 默认自带换行 \n</p>
</blockquote>
<ul>
<li>%-5s : 左对齐,宽度为5的字符串替换;默认右对齐</li>
<li>%-4.2f:指定保留2位小数</li>
</ul>
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<span class="date">2018/4/9</span>
<span>posted in&nbsp;</span>
<span class="posted-in"><a href='shell.html'>shell</a></span>
</div>
<div class="more-right right">
<span class="comments">
</span>
</div>
</div>
</div><!-- article -->
<div class="article">
<a class="clearlink" href="15226648731246.html">
<h1>每天学习一个shell技能(7)</h1>
<div class="a-content">
<div class="a-content-text">
<h2 id="toc_0">文件包含 导入文件</h2>
<p>测试文件 test1.sh</p>
<pre><code class="language-text">#!/bin/bash
# author:菜鸟教程
# url:www.runoob.com
url=&quot;http://www.runoob.com&quot;
</code></pre>
<p>测试文件 test2.sh</p>
<pre><code class="language-text">#!/bin/bash
# author:菜鸟教程
# url:www.runoob.com
#使用 . 号来引用test1.sh 文件
. ./test1.sh
# 或者使用以下包含文件代码
# source ./test1.sh
echo &quot;菜鸟教程官网地址:$url&quot;
</code></pre>
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<a href="15226648731246.html">Read more</a>&nbsp;&nbsp;
<span class="date">2018/4/2</span>
<span>posted in&nbsp;</span>
<span class="posted-in"><a href='shell.html'>shell</a></span>
</div>
<div class="more-right right">
<span class="comments">
</span>
</div>
</div>
</div><!-- article -->
<div class="article">
<a class="clearlink" href="15226603064743.html">
<h1>每天学习一个shell技能(6)</h1>
<div class="a-content">
<div class="a-content-text">
<h2 id="toc_0">test</h2>
<h3 id="toc_1">test文件</h3>
<pre><code class="language-text">if test -e ./test.sh
then
echo &#39;文件已存在!&#39;
else
echo &#39;文件不存在!&#39;
fi
</code></pre>
<ul>
<li>-e fileName : 如果文件存在则为真</li>
<li>-r fileName : 如果文件存在且可读则为真</li>
<li>-w fileName : 如果文件存在且可写则为真</li>
<li>-x fileName : 如果文件存在且可执行则为真</li>
<li>-s fileName: 文件存在且至少有一个字符</li>
<li>-d fileName : 文件存在且为目录</li>
<li>-f fileName: 文件存在且为文件</li>
<li>-c fileName:文件存在,且为字符型特殊文件</li>
<li>-b fileName: 如果文件存在且为块特殊文件则为真</li>
</ul>
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<a href="15226603064743.html">Read more</a>&nbsp;&nbsp;
<span class="date">2018/4/2</span>
<span>posted in&nbsp;</span>
<span class="posted-in"><a href='shell.html'>shell</a></span>
</div>
<div class="more-right right">
<span class="comments">
</span>
</div>
</div>
</div><!-- article -->
<div class="article">
<a class="clearlink" href="15224936933861.html">
<h1>每天学习一个shell技能(5)</h1>
<div class="a-content">
<div class="a-content-text">
<h2 id="toc_0">Shell echo命令</h2>
<h3 id="toc_1">打印字符</h3>
<pre><code class="language-text">// 下面两行代码效果一致
echo &quot;It is a test&quot;
echo It is a test
</code></pre>
<h3 id="toc_2">打印转义字符</h3>
<pre><code class="language-text">echo &quot;\&quot;It is a test\&quot;&quot;
// 引号也可以省略
echo \&quot;It is a test\&quot;
</code></pre>
<p>打印结果:</p>
<pre><code class="language-text">&quot;It is a test&quot;
&quot;It is a test&quot;
</code></pre>
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<a href="15224936933861.html">Read more</a>&nbsp;&nbsp;
<span class="date">2018/3/31</span>
<span>posted in&nbsp;</span>
<span class="posted-in"><a href='shell.html'>shell</a></span>
</div>
<div class="more-right right">
<span class="comments">
</span>
</div>
</div>
</div><!-- article -->
<div class="article">
<a class="clearlink" href="15224613481161.html">
<h1>每天学习一个shell技能(4)</h1>
<div class="a-content">
<div class="a-content-text">
<h2 id="toc_0">shell基本运算符</h2>
<p>基本使用:</p>
<pre><code class="language-text">#!/bin/bash
val=`expr 2 + 2`
echo &quot;两数之和为 : $val&quot;
</code></pre>
<ul>
<li>表达式和运算符之间要有空格,例如 2+2 是不对的,必须写成 2 + 2,这与我们熟悉的大多数编程语言不一样</li>
<li>完整的表达式要被 ` ` 包含,注意这个字符不是常用的单引号,在 Esc 键下边</li>
</ul>
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<a href="15224613481161.html">Read more</a>&nbsp;&nbsp;
<span class="date">2018/3/31</span>
<span>posted in&nbsp;</span>
<span class="posted-in"><a href='shell.html'>shell</a></span>
</div>
<div class="more-right right">
<span class="comments">
</span>
</div>
</div>
</div><!-- article -->
<div class="article">
<a class="clearlink" href="15223750607281.html">
<h1>每天学习一个shell技能 (3)</h1>
<div class="a-content">
<div class="a-content-text">
<h2 id="toc_0">shell参数传递</h2>
<p>我们可以在脚本执行时,向脚本传递参数</p>
<pre><code class="language-text">// 终端运行 脚本,并传入参数
sh testBash.sh 0 1 2
echo &quot;Shell 传递参数实例!&quot;
echo &quot;\$0 =&gt; $0&quot;
echo &quot;\$1 =&gt; $1&quot;
</code></pre>
<p>打印结果:</p>
<pre><code class="language-text">Shell 传递参数实例!
$0 =&gt; testBash.sh
$1 =&gt; 0
</code></pre>
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<a href="15223750607281.html">Read more</a>&nbsp;&nbsp;
<span class="date">2018/3/30</span>
<span>posted in&nbsp;</span>
<span class="posted-in"><a href='shell.html'>shell</a></span>
</div>
<div class="more-right right">
<span class="comments">
</span>
</div>
</div>
</div><!-- article -->
<div class="article">
<a class="clearlink" href="15223028228569.html">
<h1>每天学习一个shell技能 (1)</h1>
<div class="a-content">
<div class="a-content-text">
<h2 id="toc_0">准备</h2>
<p>bash 环境位置</p>
<pre><code class="language-text">#!/bin/bash
</code></pre>
<p><code>#!</code> 一个约定的标记,它告诉系统这个脚本需要什么解释器来执行,即使用哪一种 Shell</p>
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<a href="15223028228569.html">Read more</a>&nbsp;&nbsp;
<span class="date">2018/3/29</span>
<span>posted in&nbsp;</span>
<span class="posted-in"><a href='shell.html'>shell</a></span>
</div>
<div class="more-right right">
<span class="comments">
</span>
</div>
</div>
</div><!-- article -->
<div class="article">
<a class="clearlink" href="15223210751913.html">
<h1>每天学习一个shell 技能 (2)</h1>
<div class="a-content">
<div class="a-content-text">
<h2 id="toc_0">Shell 数组</h2>
<h3 id="toc_1">定义数组</h3>
<pre><code class="language-bash">array_name=(value1 value2 value3)
array_name2=(
value1
value2
value3
)
// 单独定义某个分量的值
array_name(0)=value0
</code></pre>
</div>
</div>
</a>
<div class="read-more clearfix">
<div class="more-left left">
<a href="15223210751913.html">Read more</a>&nbsp;&nbsp;
<span class="date">2018/3/29</span>
<span>posted in&nbsp;</span>
<span class="posted-in"><a href='shell.html'>shell</a></span>
</div>
<div class="more-right right">
<span class="comments">
</span>
</div>
</div>
</div><!-- article -->
<div class="row">
<div class="large-6 columns">
<p class="text-left" style="padding-top:25px;">
</p>
</div>
<div class="large-6 columns">
<p class="text-right" style="padding-top:25px;">
</p>
</div>
</div>
</div>
</div><!-- large 8 -->
<div class="large-4 medium-4 columns">
<div class="hide-for-small">
<div id="sidebar" class="sidebar">
<div id="site-info" class="site-info">
<div class="site-a-logo"><img src="https://ws1.sinaimg.cn/large/006tNc79ly1fmpk9088gsj30sg0sgn33.jpg" /></div>
<h1>kaelinda</h1>
<div class="site-des">倘若我心中的山水,你眼中能看到,我便一步一莲花祈祷</div>
<div class="social">
<a target="_blank" class="twitter" target="_blank" href="https://twitter.com/KaelLVLinda" title="Twitter">Twitter</a>
<a target="_blank" class="github" target="_blank" href="https://github.com/Kaelzzs" title="GitHub">GitHub</a>
<a target="_blank" class="email" href="mailto:zhouzuosong_kael@163.com" title="Email">Email</a>
<a target="_blank" class="rss" href="atom.xml" title="RSS">RSS</a>
</div>
</div>
<div id="site-categories" class="side-item ">
<div class="side-header">
<h2>Categories</h2>
</div>
<div class="side-content">
<p class="cat-list">
<a href="reactnative.html"><strong>React-Native</strong></a>
<a href="ios.html"><strong>iOS</strong></a>
<a href="app.html"><strong>MacAPP</strong></a>
<a href="swift.html"><strong>Swift</strong></a>
<a href="js.html"><strong>JavaScript</strong></a>
<a href="vue.html"><strong>Vue</strong></a>
<a href="shell.html"><strong>shell</strong></a>
<a href="%E7%BD%91%E7%BB%9C.html"><strong>网络</strong></a>
</p>
</div>
</div>
<div id="site-categories" class="side-item">
<div class="side-header">
<h2>Recent Posts</h2>
</div>
<div class="side-content">
<ul class="posts-list">
<li class="post">
<a href="15523077857608.html">OC中枚举写法 以及 字符串枚举探索</a>
</li>
<li class="post">
<a href="15522686353535.html">iOS 动画全解 (1)</a>
</li>
<li class="post">
<a href="15501356584731.html">UITableView顶部空白的几种解决办法</a>
</li>
<li class="post">
<a href="15488351784332.html">Objective-C中的字符串类型枚举 探索</a>
</li>
<li class="post">
<a href="15409691048860.html">【Swift笔记】引用计数</a>
</li>
</ul>
</div>
</div>
</div><!-- sidebar -->
</div><!-- hide for small -->
</div><!-- large 4 -->
</div><!-- row -->
<div class="page-bottom clearfix">
<div class="row">
<p class="copyright">Copyright &copy; 2015
Powered by <a target="_blank" href="http://www.mweb.im">MWeb</a>,&nbsp;
Theme used <a target="_blank" href="http://github.com">GitHub CSS</a>.</p>
</div>
</div>
</section>
</div>
</div>
<script src="asset/js/foundation.min.js"></script>
<script>
$(document).foundation();
function fixSidebarHeight(){
var w1 = $('.markdown-body').height();
var w2 = $('#sidebar').height();
if (w1 > w2) { $('#sidebar').height(w1); };
}
$(function(){
fixSidebarHeight();
})
$(window).load(function(){
fixSidebarHeight();
});
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script><script type="text/x-mathjax-config">MathJax.Hub.Config({TeX: { equationNumbers: { autoNumber: "AMS" } }});</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kaelinda/kaelindaTop.git
git@gitee.com:kaelinda/kaelindaTop.git
kaelinda
kaelindaTop
kaelindaTop
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385