?? 04.常用命令集四.htm
字號:
<!--本網(wǎng)頁文件由電子書制作工具“電子文檔處理器”未注冊版本的Txt2Html功能自動生成 -->
<!-- Made by an Unregistered version of eTextWizard V 1.98-->
<!--“電子文檔處理器”軟件作者: 馮國華 -->
<!--“電子文檔處理器”下載地址: http://www.etextwizard.com/download/ew/etextwizard.exe -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>04.常用命令集四</title>
<META NAME="keywords" CONTENT="電子文檔處理器,etextwizard,ebook maker">
<META NAME="description" CONTENT="電子文檔處理器是一款文檔格式轉(zhuǎn)換、文檔處理軟件集,批量電子書制作工具,幫助文件及技術(shù)資料的快速制作工具。網(wǎng)址:http://www.eTextWizard.com">
<meta name="GENERATOR" content="電子文檔處理器,etextwizard">
<style>
<!--
body { line-height: 20px}
td { line-height: 20px}
.Paragraph{ font-size: 9pt }
.9{ font-size: 9pt }
A:link {text-decoration: none; color:#0033CC}
A:visited {text-decoration: none; color: #0033CC}
A:active {text-decoration: none; color: #0000ff }
A:hover {text-decoration: underline; color: #FF0000 }
-->
</style>
</head>
<body bgcolor="#FFFFFF">
<div align="center"><center>
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td width="80%" bgcolor="#000000">
<table border="0" cellspacing="1" width="100%" cellpadding="6" height="98">
<tr>
<td width="100%" bgcolor="#FFFFFD" height="20">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="49%"><p class="9"><font color="#FF0000"> </font></td>
<td width="51%"><p align="right" class="9"><a href="03.常用命令集三.htm">上一頁</a> <a href="index.html">首頁</a> <a href="05.Linux備份與壓縮命令.htm">下一頁</a></td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#DFE0D1">
<td width="100%" height="21">
<p align="center"><strong>04.常用命令集四</strong>
</td>
</tr>
<tr bgcolor="#F5F7EE">
<td width="100%" height="51" align=center>
<table><tr><td>
<p class="Paragraph">
我們一起在風雨中前行<br>
<br>
名稱:expr<br>
使用權(quán)限:所有使用者<br>
### 字串長度<br>
shell>> expr length "this is a test"<br>
14<br>
### 數(shù)字商數(shù)<br>
shell>> expr 14 % 9<br>
5<br>
### 從位置處抓取字串<br>
shell>> expr substr "this is a test" 3<br>
5<br>
is is<br>
### 數(shù)字串 only the first character<br>
shell>> expr index "testforthegame" e<br>
<br>
2<br>
### 字串真實重現(xiàn)<br>
shell>> expr quote thisisatestformela<br>
thisisatestformela<br>
名稱: tr<br>
### 1.比方說要把目錄下所有的大寫檔名換為小寫檔名?<br>
似乎有很多方式,"tr"是其中一種:<br>
#!/bin/sh<br>
dir="/tmp/testdir";<br>
files=`find $dir -type f`;<br>
for i in $files<br>
do<br>
dir_name=`dirname $i`;<br>
ori_filename=`basename $i`<br>
new_filename=`echo $ori_filename | tr [:upper:] [:lower:]` > /dev/null;<br>
<br>
#echo $new_filename;<br>
mv $dir_name/$ori_filename $dir_name/$new_filename<br>
done<br>
<br>
### 2.自己試驗中...lowercase to uppercase<br>
tr abcdef...[del] ABCDE...[del]<br>
tr a-z A-Z<br>
tr [:lower:] [:upper:]<br>
shell>> echo "this is a test" | tr a-z<br>
A-Z > www<br>
shell>> cat www<br>
THIS IS A TEST<br>
### 3.去掉不想要的字串<br>
shell>> tr -d this ### 去掉有關(guān) t.e.s.t<br>
this<br>
man<br>
man<br>
test<br>
e<br>
### 4.取代字串<br>
shell>> tr -s "this" "TEST"<br>
<br>
this<br>
TEST<br>
th<br>
TE<br>
<br>
指令:clear<br>
用途:清除屏幕用。<br>
使用方法:在 console 上輸入 clear。<br>
<br>
名稱: reset, tset<br>
使用方法: tset [-IQqrs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]<br>
<br>
使用說明:<br>
reset 其實和 tset 是一同個命令,它的用途是設定終端機的狀態(tài)。一般而言,這個命令會自動的從環(huán)境變數(shù)、命令列或是其它的組態(tài)檔決定目前終端機的型態(tài)。如果指定型態(tài)是<br>
? 的話,這個程式會要求使用者輸入終端機的型別。<br>
軟驅(qū)片 由于這個程式會將終端機設回原始的狀態(tài),除了在 login 時使用外,當系統(tǒng)終端機因為程式不正常執(zhí)行而進入一些奇怪的狀態(tài)時,你也可以用它來重設終端機o<br>
例如不小心把二進位檔用 cat 指令進到終端機,常會有終端機不再回應鍵盤輸入,或是回應一些奇怪字元的問題。此時就可以用 reset 將終端機回復至原始狀態(tài)。<br>
<br>
參數(shù):<br>
-p 將終端機類別顯示在螢幕上,但不做設定的動作。這個命令可以用來取得目前終端機的類別。<br>
-e ch 將 erase 字元設成 ch<br>
-i ch 將中斷字元設成 ch<br>
-k ch 將刪除一行的字元設成 ch<br>
-I 不要做設定的動作,如果沒有使用選項 -Q 的話,erase、中斷及刪除字元的目前值依然會送到螢幕上。<br>
-Q 不要顯示 erase、中斷及刪除字元的值到螢幕上。<br>
-r 將終端機類別印在螢幕上。<br>
-s 將設定 TERM 用的命令用字串的型式送到終端機中,通常在 .login 或 .profile 中用<br>
<br>
范例:<br>
讓使用者輸入一個終端機型別并將終端機設到該型別的預設狀態(tài)。<br>
# reset ?<br>
將 erase 字元設定 control-h<br>
# reset -e ^B<br>
將設定用的字串顯示在螢幕上<br>
# reset -s<br>
Erase is control-B (^B).<br>
Kill is control-U (^U).<br>
Interrupt is control-C (^C).<br>
TERM=xterm;<br>
名稱:compress<br>
使用權(quán)限:所有使用者<br>
使用方式:compress [-dfvcV] [-b maxbits] [file ...]<br>
<br>
說明:<br>
compress 是一個相當古老的 unix 檔案壓縮指令,壓縮后的檔案會加上一個 .Z 延伸檔名以區(qū)別未壓縮的檔案,壓縮后的檔案可以以 uncompress<br>
解壓。若要將數(shù)個檔案壓成一個壓縮檔,必須先將檔案 tar 起來再壓縮。由于 gzip 可以產(chǎn)生更理想的壓縮比例,一般人多已改用 gzip 為檔案壓縮工具。<br>
<br>
參數(shù):<br>
c 輸出結(jié)果至標準輸出設備(一般指熒幕)<br>
f 強迫寫入檔案,若目的檔已經(jīng)存在,則會被覆蓋 (force)<br>
v 將程式執(zhí)行的訊息印在熒幕上 (verbose)<br>
b 設定共同字串數(shù)的上限,以位元計算,可以設定的值為 9 至 16 bits 。由于值越大,能使用的共同字串就 越多,壓縮比例就越大,所以一般使用預設值<br>
16 bits (bits)<br>
d 將壓縮檔解壓縮<br>
V 列出版本訊息<br>
<br>
范例:<br>
將 source.dat 壓縮成 source.dat.Z ,若 source.dat.Z 已經(jīng)存在,內(nèi)容則會被壓縮檔覆蓋。<br>
<br>
compress -f source.dat<br>
將 source.dat 壓縮成 source.dat.Z ,并列印出壓縮比例。<br>
<br>
-v 與 -f 可以一起使用<br>
compress -vf source.dat<br>
將壓縮后的資料輸出后再導入 target.dat.Z 可以改變壓縮檔名。<br>
compress -c source.dat > target.dat.Z<br>
-b 的值越大,壓縮比例就越大,范圍是 9-16 ,預設值是 16 。<br>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -