国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

不就是抽個血嗎,至于么-jQuery,Linux完結篇

2019-11-14 14:38:07
字體:
來源:轉載
供稿:網友

  hi

趁著周一去抽血化驗,真開心。。。下午報告才出來,不過早上來了就開始各種暈菜,叫錯名字,說錯話。。。。。至于么。。

 還有在教研室的30天就可以肥家了,凱森凱森。今天不想干活(哪天想干過我就問問),學學jquery吧。

1、jQuery

十、UI型插件

10.1 拖曳插件——draggable

拖曳插件draggable的功能是拖動被綁定的元素,當這個jQuery UI插件與元素綁定后,可以通過調用draggable()方法,實現各種拖曳元素的效果,調用格式如下:

$(selector). draggable({options})

options參數為方法調用時的配置對象,根據該對象可以設置各種拖曳效果,如“containment”屬性指定拖曳區域,“axis”屬性設置拖曳時的坐標方向。

<body>
<div id="divtest">
<div id="x" class="drag">沿x軸拖拽</div>
<div id="y" class="drag">沿y軸拖拽</div>
</div>

<script type="text/javascript">
$(function () {
$("#x").draggable({axis:"x"});
$("#y").draggable({axis:"y"});
});
</script>
</body>

10.2 放置插件——droppable

除使用draggable插件拖曳任意元素外,還可以調用droppable UI插件將拖曳后的任意元素放置在指定區域中,類似購物車效果,調用格式如下:

$(selector).droppable({options})

selector參數為接收拖曳元素,options為方法的配置對象,在對象中,drop函數表示當被接收的拖曳元素完全進入接收元素的容器時,觸發該函數的調用。

<body>
<div id="divtest">
<div class="box">
<div class="title">產品區</div>
<div class="drag"><div>蘋果</div></div>
</div>
<div class="box">
<div class="title">回收站</div>
<div class="cart"><div id="tip">還沒有產品</div></div>
</div>
</div>

<script type="text/Javascript">
$(function () {
$(".drag").draggable();
$(".cart").droppable({
drop: function () {
sum--;
$(".cart").removeClass("focus");
$("#tip").html("還沒有產品");
$(".title span").html(sum);
}
})
});
</script>
</body>

10.3 拖曳排序插件——sortable

拖曳排序插件的功能是將序列元素(例如<option>、<li>)按任意位置進行拖曳從而形成一個新的元素序列,實現拖曳排序的功能,它的調用格式為:

$(selector).sortable({options});

selector參數為進行拖曳排序的元素,options為調用方法時的配置對象

<body>
<div id="divtest">
<div class="title">
<span class="fl">我最喜歡的運動</span>
</div>
<div class="content">
<ul>
<li>1)足球</li>
<li>2)散步</li>
<li>3)籃球</li>
<li>4)乒乓球</li>
<li>5)騎自行車</li>
</ul>
</div>
</div>

<script type="text/javascript">
$(function () {
$("ul").sortable({
delay:2,
opacity:0.4
})
});
</script>
</body>

10.4 面板折疊插件——accordion

面板折疊插件可以實現頁面中指定區域類似“手風琴”的折疊效果,即點擊標題時展開內容,再點另一標題時,關閉已展開的內容,調用格式如下:

$(selector).accordion({options});

其中,參數selector為整個面板元素,options參數為方法對應的配置對象。

<body>
<div id="divtest">
<div id="accordion">
<h3>
<a href="#">白富美</a></h3>
<p>咱們結婚吧!</p>
<h3>
<a href="#">土豪族</a></h3>
<p>咱們交個朋友吧!</p>
</div>
</div>

<script type="text/javascript">
$(function () {
$("#accordion").accordion();
});
</script>
</body>

10.5 選項卡插件——tabs

使用選項卡插件可以將<ul>中的<li>選項定義為選項標題,在標題中,再使用<a>元素的“href”屬性設置選項標題對應的內容,它的調用格式如下:

$(selector).tabs({options});

selector參數為選項卡整體外圍元素,該元素包含選項卡標題與內容,options參數為tabs()方法的配置對象,通過該對象還能以Ajax方式加載選項卡的內容。

<body>
<div id="divtest">
<div id="tabs">
<ul>
<li><a href="#tabs-1">最愛吃的水果</a></li>
<li><a href="#tabs-2">最喜歡的運動</a></li>
</ul>
<div id="tabs-1">
<p>橘子</p>
<p>香蕉</p>
<p>葡萄</p>
<p>蘋果</p>
<p>西瓜</p>
</div>
<div id="tabs-2">
<p>足球</p>
<p>散步</p>
<p>籃球</p>
<p>乒乓球</p>
<p>騎自行車</p>
</div>
</div>
</div>

<script type="text/javascript">
$(function () {
$("#tabs").tabs ({
//設置各選項卡在切換時的動畫效果
fx: { opacity: "toggle", height: "toggle" },
event: "mousemove" //通過移動鼠標事件切換選項卡
})
});
</script>
</body>

10.6 對話框插件——dialog

對話框插件可以用動畫的效果彈出多種類型的對話框,實現JavaScript代碼中alert()confirm()函數的功能,它的調用格式為:

$(selector).dialog({options});

selector參數為顯示彈出對話框的元素,通常為<div>,options參數為方法的配置對象,在對象中可以設置對話框類型、“確定”、“取消”按鈕執行的代碼等。

<body>
<div id="divtest">
<div class="content">
<span id="spnName" class="fl">張三</span>
<input id="btnDelete" type="button" value="刪除" class="fr"/>
</div>
<div id='dialog-modal'></div>
</div>

<script type="text/javascript">
$(function () {
$("#btnDelete").bind("click", function () { //詢問按鈕事件
if ($("#spnName").html() != null) { //如果對象不為空
sys_Confirm("您真的要刪除該條記錄嗎?");
return false;
}
});
});
function sys_Confirm(content) { //彈出詢問信息窗口
$("#btnDelete").dialog({
height: 140,
modal: true,
title: '系統提示',
hide: 'slide',
buttons: {
'確定': function () {
$("#spnName").remove();
$(this).dialog("close");
},
'取消': function () {
$(this).dialog("close");
}
},
open: function (event, ui) {
$(this).html("");
$(this).append("<p>" + content + "</p>");
}
});
}
</script>
</body>

10.7 菜單工具插件——menu

菜單工具插件可以通過<ul>創建多級內聯或彈出式菜單,支持通過鍵盤方向鍵控制菜單滑動,允許為菜單的各個選項添加圖標,調用格式如下:

$(selector).menu({options});

selector參數為菜單列表中最外層<ul>元素,options為menu()方法的配置對象。

<body>
<ul id="menu">
<li><a href="#">小明一中</a>
<ul>
<li><a href="#">高中部</a>
<ul>
<li><a href="#">高一(1)班</a></li>
<li><a href="#">高一(2)班</a></li>
<li><a href="#">高一(3)班</a>
<ul>
<li><a href="#">小胡</a></li>
<li><a href="#">小李</a></li>
<li><a href="#">小陳</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">初中部</a>
<ul>
<li><a href="#">初一(1)班</a></li>
<li><a href="#">初一(2)班</a></li>
<li><a href="#">初一(3)班</a></li>
</ul>
</li>
<li><a href="#">教研部</a></li>
</ul>
</li>
<li class="ui-state-disabled"><a href="#">大明二中</a></li>
</ul>

<script type="text/javascript">
$(function () {
$("#menu").menu();
});
</script>
</body>

10.8 微調按鈕插件——spinner

微調按鈕插件不僅能在文本框中直接輸入數值,還可以通過點擊輸入框右側的上下按鈕修改輸入框的值,還支持鍵盤的上下方向鍵改變輸入值,調用格式如下:

$(selector).spinner({options});

selector參數為文本輸入框元素,可選項options參數為spinner()方法的配置對象,在該對象中,可以設置輸入的最大、最小值,獲取改變值和設置對應事件。

<body>
<div id="divtest">
<div class="title">
選擇顏色值</div>
<div class="content">
<span id="spnColor" class="input fl">
<input />
</span>
<span id="spn

Chrome為true,表示當前為Chrome瀏覽器,$.browser.mozilla為true,表示當前為火狐瀏覽器,還可以通過$.browser.version方式獲取瀏覽器版本信息。

<body>
<div id="divtest">
<div class="title">
<span class="fl">獲取瀏覽器名稱和版本號</span>
</div>
<div class="content"></div>
</div>

<script type="text/javascript">
$(function () {
var strTmp = "您的瀏覽器名稱是:";
if ($.browser.chrome) { //谷歌瀏覽器
strTmp += "Chrome";
}
if ($.browser.mozilla) { //火狐相關瀏覽器
strTmp += "Mozilla Firefox";
}
strTmp += "<br /><br /> 版本號是:" //獲取版本號
+$.browser.version;
$(".content").html(strTmp);
});
</script>
</body>

很簡單的一點,但是,要注意,jQuery的方法,一般是$(),函數常常是$.(?)

11.2 檢測瀏覽器是否屬于W3C盒子模型

瀏覽器的盒子模型分為兩類,一類為標準的w3c盒子模型,另一類為IE盒子模型,兩者區別為在Width和Height這兩個屬性值中是否包含padding和border的值,w3c盒子模型不包含,IE盒子模型則包含,而在jQuery 中,可以通過$.support.boxModel對象返回的值,檢測瀏覽器是否屬于標準的w3c盒子模型。

<body>
<div id="divtest">
<div class="title">
<span class="fl">檢測是否是盒子模型</span>
</div>
<div class="content"></div>
</div>

<script type="text/javascript">
$(function () {
var strTmp = "您打開的頁面是:";
if ($.support.boxModel) { //是W3C盒子模型
strTmp += "W3C盒子模型";
}
else { //是IE盒子模型
strTmp += "IE盒子模型";
}
$(".content").html(strTmp);
});
</script>
</body>

11.3 檢測對象是否為空

在jQuery中,可以調用名為$.isEmptyObject的工具函數,檢測一個對象的內容是否為空,如果為空,則該函數返回true,否則,返回false值,調用格式如下:

$.isEmptyObject(obj);

其中,參數obj表示需要檢測的對象名稱。

<body>
<div id="divtest">
<div class="title">
<span class="fl">檢測對象是否為空</span>
</div>
<div class="content"></div>
</div>

<script type="text/javascript">
$(function () {
var obj = { "姓名": "土豪一族" };
var strTmp = "您定義了一個:";
if ($.isEmptyObject(obj)) { //檢測是否為空
strTmp += "空對象";
}
else {
strTmp += "非空對象";
}
$(".content").html(strTmp);
});
</script>
</body>

11.4 檢測對象是否為原始對象

調用名為$.isPlainObject的工具函數,能檢測對象是否為通過{}new Object()關鍵字創建的原始對象,如果是,返回true,否則,返回false值,調用格式為:

$.isPlainObject (obj);

其中,參數obj表示需要檢測的對象名稱。

<body>
<div id="divtest">
<div class="title">
<span class="fl">檢測對象是否為原始對象</span>
</div>
<div class="content"></div>
</div>

<script type="text/javascript">
$(function () {
var obj = "null";
var strTmp = "您定義了一個:";
if ($.isPlainObject(obj)) { //檢測是否為原始對象
strTmp += "原始對象";
}
else {
strTmp += "非原始對象";
}
$(".content").html(strTmp);
});
</script>
</body>

11.5 檢測兩個節點的包含關系

調用名為$.contains的工具函數,能檢測在一個DOM節點中是否包含另外一個DOM節點,如果包含,返回true,否則,返回false值,調用格式為:

$.contains (container, contained);

參數container表示一個DOM對象節點元素,用于包含其他節點的容器,contained是另一個DOM對象節點元素,用于被其他容器所包含。

<body>
<div id="divtest">
<div class="title">
<span class="fl">檢測兩個節點的包含關系</span>
</div>
<div class="content"></div>
</div>

<script type="text/javascript">
$(function () {
var node_a = document.body.firstChild;
var node_b = document.body;
var strTmp = "對象node_a";
if ($.contains(node_a,node_b)) { //檢測是否包含節點
strTmp += " 包含 ";
}
else {
strTmp += " 不包含 ";
}
strTmp += "對象node_b";
$(".content").html(strTmp);
});
</script>
</body>

11.6 字符串操作函數

調用名為$.trim的工具函數,能刪除字符串中左右兩邊的空格符,但該函數不能刪除字符串中間的空格,調用格式為:

$.trim (str);

參數str表示需要刪除左右兩邊空格符的字符串。

<body>
<div id="divtest">
<div class="title">
<span class="fl">字符串操作函數</span>
<span class="fr">
<input id="btnShow" name="btnShow" type="button" value="計算" />
</span>
</div>
<div class="content">
<input id="txtName" name="txtName" type="text" />
<div class="tip"></div>
</div>
</div>

<script type="text/javascript">
$(function () {
$("#btnShow").bind("click", function () {
$(".tip").html("");
var strTmp = "內容:";
var strOld = $("#txtName").val();
var strNew =$.trim(strOld);
strTmp += strOld;
strTmp += "<br/><br>除掉空格符前的長度:"
strTmp += strOld.length;
strTmp += "<br/><br>除掉空格符后的長度:"
strTmp += strNew.length;
$(".tip").show().append(strTmp);
});
});
</script>
</body>

11.7 URL操作函數

調用名為$. param的工具函數,能使對象或數組按照key/value格式進行序列化編碼,該編碼后的值常用于向服務端發送URL請求,調用格式為:

$. param (obj);

參數obj表示需要進行序列化的對象,該對象也可以是一個數組,整個函數返回一個經過序列化編碼后的字符串。

<body>
<div id="divtest">
<div class="title">
<span class="fl">URL操作函數</span>
</div>
<div class="content">
<div class="tip"></div>
</div>
</div>

<script type="text/javascript">
$(function () {
//基本信息對象
var objInfo = new Object();
objInfo.name = "白富美";
objInfo.sex = 1;
//序列化對象
var objNewInfo =$.param(objInfo.name);
//顯示序列化后的對象
var strTmp = "<b>對象 白富美 序列化后</b>:<br/><br/>";
strTmp += objNewInfo;
//顯示在頁面中
$(".tip").show().append(strTmp);
});
</script>
</body>

11.8 使用$.extend()擴展工具函數

調用名為$. extend的工具函數,可以對原有的工具函數進行擴展,自定義類級別的jQuery插件,調用格式為:

$. extend ({options});

參數options表示自定義插件的函數內容。

<body>
<div id="divtest">
<div class="title">
<span class="fl">自定義工具函數求兩值中最小值</span>
<span class="fr">
<input id="btnShow" name="btnShow" type="button" value="計算" />
</span>
</div>
<div class="content">
<div class="tip"></div>
</div>
</div>

<script type="text/javascript">
/*------------------------------------------------------------/
功能:返回兩個數中最小值
參數:數字p1,p2
返回:最小值的一個數
示例:$.MinNum(1,2);
/------------------------------------------------------------*/
(function ($) {
$.extend({
"MinNum": function (p1, p2) {
return (p1 > p2) ? p2 : p1;
}
});
})(jQuery);
$(function () {
$("#btnShow").bind("click", function () {
$(".tip").html("");
var strTmp = "17與18中最小的數是:";
strTmp +=$.MinNum(17, 18);
//顯示在頁面中
$(".tip").show().append(strTmp);
});
});
</script>
</body>

11.9 使用$.extend()擴展Object對象

除使用$.extend擴展工具函數外,還可以擴展原有的Object對象,在擴展對象時,兩個對象將進行合并,當存在相同屬性名時,后者將覆蓋前者,調用格式為:

$. extend (obj1,obj2,…objN);

參數obj1至objN表示需要合并的各個原有對象。

<body>
<div id="divtest">
<div class="title">
<span class="fl">合并原有對象</span>
</div>
<div class="content">
<div class="tip"></div>
</div>
</div>

<script type="text/javascript">
$(function () {
var objInfo = { name: "" };
var objMess = { name: "白富美,", title: "歡迎與我聯系!" };
var objNewInfo =$.extend(objInfo,objMess);
var strTmp = "<b>對象 白富美 合并后</b>:<br/><br/>";
strTmp += objNewInfo.name + objInfo.title;
//顯示在頁面中
$(".tip").show().append(strTmp);
});
</script>
</body>

 

 十二、在線聊天室實踐

12.1 基本功能介紹

登陸后才能進入(基本信息的顯示);

動態顯示交流后的內容;

文字和表情的溝通實現(表情也是字符代號編碼)

技術重點:ajax的無刷新技術展示數據

12.2 實現效果

利用jq中的ajax函數實現登陸,登陸時,顯示登陸中,正確或失敗,有相應的動作;

聊天室就是聊天內容區域,輸入區域,人員顯示區域

 

 

 

---------------------------------------------------

2、linux完結篇

九、shell基礎

9.1shell概述

--含義

就是其英文單詞的意思——殼

是一個命令行解釋器!——翻譯依賴的是ASCII碼,依賴它把命令翻譯為二進制的,讓內核能夠解析命令。

也就是:用戶寫命令《--》shell解釋翻譯《--》內核

換言之,就是我們操作的界面。

但是,在linux特殊的在于,shell還是一個功能強大的編程語言,易編寫,易調試,靈活性較強。

是解釋執行的腳本語言,在shell中可以直接調用linux命令。

--分類

當前一般兩類:Bourne shell(linux用的就是其下的Bash)和C shell(Unix中的,與c語言相似)

絕大多數的命令是通用的(包括linux和unix),根本原因在于都用shell,版本有差別而已。

[root@andy ~]# echo $SHELL
/bin/bash

這個命令可以看到當前的shell

--linux支持的

vi /etc/shells

打開一個文件

/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/tcsh
/bin/csh

這些都支持

9.2 腳本執行方式

--echo命令

就是打印嘛。

但和php中不太一樣的是,要輸出換行的/n時候需要這樣

[root@andy ~]# echo -e "aldkjf/nadsf"
aldkjf
adsf

需要加選項-e。

linux本機中是無法支持中文字符,遠程工具是可以的

[root@andy ~]# echo -e "/e[1;31m嫁人就要嫁鳳姐/e[0m"
嫁人就要嫁鳳姐

上個例子:/e[1;31m是開啟顏色顯示,/e[0m結束

31是紅色,一直到40好像是,自己試試吧

--腳本

vi hello.sh

#!/bin/bash
#The first program

echo -e "/e[1;34m 天下掉下個林妹妹 /e[0m"

要先寫入bash的那句話,盡量避免報錯。

然后#后面的一般都是注釋

shell的好處就是可以直接輸出

但,暫時還不能運行——

--執行

賦予權限,直接運行——chmod 755 hello.sh, ./hello.sh

或者,bash命令,bash hello.sh

應該說,最好還是用賦予權限然后(絕對路徑)運行

9.3bash的基本功能

9.3.1 命令別名與快捷鍵

--

命令別名==人的小名/外號

[root@andy ~]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

alias命令,可以查看別名。所以,我們設定別名也是上面的格式:alias cp='cp -i'

alias 別名=‘原命令’

重啟的話會失效,要想一直有效,要寫入對應的環境變量配置文件

vi ~/.bashrc

[root@andy ~]# vi /root/.bashrc

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
~

寫入alias vi='vim'即可

unalias 別名,就是刪除別名。同樣,命令行的是臨時刪除

另外,命令的執行順序,別名是優先級別第二高的 

路徑+命令》別名》bash命令》目錄中查到的第一條命令

即,別名比原名級別高,或者,避免重疊/重復,除非你的目的就是這個

--快捷鍵

ctrl+c 強制終止

     +l 清屏

     +a 移到命令行首(home)

     +u 刪除命令到行首

     +e 跳到行尾(end)

     +z 把命令放入后臺(沒有終止命令,少用)

     +r 在歷史命令中搜索

9.3.2 歷史命令

上下箭頭調用就好。

[root@andy ~]# history

該命令會顯示所有你/當前用戶輸入過的所有歷史命令。所有的歷史命令是保存在.bash_history文件中的

history -c 清空歷史命令。一般來說,最好不要清空歷史命令——查錯,以及防賊

history !n 重復執行第n條命令

history !! 重復執行上一條命令

history !字符串 調用最后一個以該字符串開頭的命令(常用)

9.3.3 輸出重定向

--標準輸入輸出

鍵盤——/dev/stdin 文件描述符為0

顯示器——/dev/sdtout 文件描述符為1

顯示器——/dev/sdterr 文件描述符為2,類型是標準錯誤輸出

背就背文件描述符就好了

--輸出重定向

就是把原本應該標準輸出的方向重新定向到文件(拐個彎)。

用處就是自動的記錄等,有實際的用處,也常用。

比如

[root@andy ~]# ifconfig > test.log
[root@andy ~]# cat test.log
eth0 Link encap:Ethernet HWaddr 00:0C:29:61:EB:6B
inet addr:192.168.23.50 Bcast:192.168.23.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe61:eb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11069 errors:0 dropped:0 overruns:0 frame:0
TX packets:3521 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:798686 (779.9 KiB) TX bytes:447837 (437.3 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1532 (1.4 KiB) TX bytes:1532 (1.4 KiB)

命令的執行,可能會是定時用戶來做的。

[root@andy ~]# ls > test.log
[root@andy ~]# cat test.log
anaconda-ks.cfg
cangls
hello.sh
install.log
install.log.syslog
japan
test.log

單個>,會覆蓋結果;雙>>是追加

[root@andy ~]# ifconfig >> test.log
[root@andy ~]# cat test.log
anaconda-ks.cfg
cangls
hello.sh
install.log
install.log.syslog
japan
test.log
eth0 Link encap:Ethernet HWaddr 00:0C:29:61:EB:6B
inet addr:192.168.23.50 Bcast:192.168.23.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe61:eb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11238 errors:0 dropped:0 overruns:0 frame:0
TX packets:3586 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:811445 (792.4 KiB) TX bytes:455539 (444.8 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1532 (1.4 KiB) TX bytes:1532 (1.4 KiB)

如果希望同時保存報錯信息(犯2信息)

dateads 2>>test.log

另外注意,追加是有空格,錯誤輸出是沒有空格的2>>test.log

 

但是,最有用的是正確和錯誤都要

命令 >> 文件 2>&1  

命令 &>> 文件  ——寫到同一個文件

[root@andy ~]#
[root@andy ~]# ifconfig >> test2.log 2>&1
[root@andy ~]# cat test2.log
eth0 Link encap:Ethernet HWaddr 00:0C:29:61:EB:6B
inet addr:192.168.23.50 Bcast:192.168.23.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe61:eb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11444 errors:0 dropped:0 overruns:0 frame:0
TX packets:3638 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:825629 (806.2 KiB) TX bytes:461351 (450.5 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1532 (1.4 KiB) TX bytes:1532 (1.4 KiB)

[root@andy ~]# ifconfig2 >> test2.log 2>&1
[root@andy ~]# cat test2.log
eth0 Link encap:Ethernet HWaddr 00:0C:29:61:EB:6B
inet addr:192.168.23.50 Bcast:192.168.23.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe61:eb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11444 errors:0 dropped:0 overruns:0 frame:0
TX packets:3638 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:825629 (806.2 KiB) TX bytes:461351 (450.5 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1532 (1.4 KiB) TX bytes:1532 (1.4 KiB)

-bash: ifconfig2: command not found

 命令>>文件1 2>>文件2  ——分開保存

 這三個操作是這一塊需要記下來的!

--輸入重定向

 wc命令

[root@andy ~]# wc
sadklfjkla
asdlkfjl
asdf^[[3~asdlfj
asdf
4 4 40

統計了你輸入的字符長度。

 很少用,大概了解下

命令<文件

命令<<文件

9.3.4 管道符

 --多命令順序執行

; 命令1;命令2 多個命令無邏輯關系按順序執行

&& 邏輯與,其他一樣——1成功,2才執行

||   或——1或2只執行一個

[root@andy ~]# ls ; ifconfig
anaconda-ks.cfg cangls hello.sh install.log install.log.syslog japan test2.log test3.log test.log
eth0 Link encap:Ethernet HWaddr 00:0C:29:61:EB:6B
inet addr:192.168.23.50 Bcast:192.168.23.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe61:eb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12241 errors:0 dropped:0 overruns:0 frame:0
TX packets:3901 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:884175 (863.4 KiB) TX bytes:489889 (478.4 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1532 (1.4 KiB) TX bytes:1532 (1.4 KiB)

[root@andy ~]# ls && ifconfig
anaconda-ks.cfg cangls hello.sh install.log install.log.syslog japan test2.log test3.log test.log
eth0 Link encap:Ethernet HWaddr 00:0C:29:61:EB:6B
inet addr:192.168.23.50 Bcast:192.168.23.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe61:eb6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12289 errors:0 dropped:0 overruns:0 frame:0
TX packets:3926 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:887929 (867.1 KiB) TX bytes:493627 (482.0 KiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1532 (1.4 KiB) TX bytes:1532 (1.4 KiB)

[root@andy ~]# ls || config
anaconda-ks.cfg cangls hello.sh install.log install.log.syslog japan test2.log test3.log test.log

當然,;可以順序執行很多命令

[root@andy ~]# ls ; ifconfig ; cd ;history

再看第二個

[root@andy ~]# ls && echo "yes"
anaconda-ks.cfg cangls hello.sh install.log install.log.syslog japan test2.log test3.log test.log
yes

適用于具有(簡單)邏輯關系的情況,比如LAMP安裝

簡單的實現判斷命令是否正確

[root@andy ~]# ls && echo yes || echo no
anaconda-ks.cfg cangls hello.sh install.log install.log.syslog japan test2.log test3.log test.log
yes

--管道符

|

也是多命令順序執行。區別在于,命令一的正確輸出作為命令2的操作對象

[root@andy ~]# ls -l /etc | more

所以,相應來說,管道符的命令要更加嚴格一點

[root@andy ~]# netstat -an | grep ESTABLISHED | wc -l
1

這個是以后常用的服務器的命令

9.3.5 通配符

--

可以匹配其他字符的符號

? * [] [a-z] [^0-9]

真的就類似正則表達式中的東西。

用法

[root@andy ~]# ls ja*
anaconda-ks.cfg cangls juls
[root@andy ~]# ls japan
anaconda-ks.cfg cangls juls

主要用來匹配文件名或者目錄的東西;要匹配文件中的內容,就真的用正則表達式了

--特殊

$變量,取變量的值

‘’ 單引號中所有的特殊符號($`反引號)都沒有意義;“”,特殊字符中的/ ` $有含義

$(),用來引用系統命令,和反引號一樣,但推薦使用這個

[root@andy ~]# aa=$(ls)
[root@andy ~]# $aa
-bash: anaconda-ks.cfg: command not found
[root@andy ~]# echo $aa
anaconda-ks.cfg cangls hello.sh install.log install.log.syslog japan test2.log test3.log test.log
[root@andy ~]# echo '$aa'
$aa
[root@andy ~]# echo "$aa"
anaconda-ks.cfg
cangls
hello.sh
install.log
install.log.syslog
japan
test2.log
test3.log
test.log

 

 

 

 

 

 

 

 

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 米泉市| 永和县| 财经| 承德市| 新安县| 邵东县| 鸡西市| 福建省| 屯昌县| 同仁县| 宜川县| 綦江县| 南岸区| 玉林市| 乌苏市| 嘉黎县| 博客| 黄冈市| 威宁| 苍溪县| 明水县| 揭阳市| 昆山市| 宁明县| 仁怀市| 晋中市| 肇州县| 镶黄旗| 永丰县| 安阳县| 南通市| 同心县| 瓮安县| 涪陵区| 盘山县| 阳朔县| 巍山| 昔阳县| 翼城县| 哈巴河县| 金乡县|