|
Linux 指令大全(14)
|
|
来源: 作者:方舟 发布时间:2007-11-09
|
|
stvista
名称:expr
使用权限:所有使用者 ### 字串长度
shell>> expr length "this is a test" 14
### 数字商数
shell>> expr 14 % 9 5
### 从位置处抓取字串
shell>> expr substr "this is a test" 3 5 is is
### 数字串 only the first character
shell>> expr index "testforthegame" e 2
### 字串真实重现
shell>> expr quote thisisatestformela thisisatestformela
名称: tr
### 1.比方说要把目录下所有的大写档名换为小写档名?
似乎有很多方式,"tr"是其中一种:
#!/bin/sh
dir="/tmp/testdir"; files=`find $dir -type f`; for i in $files do dir_name=`dirname $i`; ori_filename=`basename $i` new_filename=`echo $ori_filename | tr [:upper:] [:lower:]` > /dev/null; #echo $new_filename; mv $dir_name/$ori_filename $dir_name/$new_filename done
### 2.自己试验中...lowercase to uppercase
tr abcdef...[del] ABCDE...[del] tr a-z A-Z tr [:lower:] [:upper:]
shell>> echo "this is a test" | tr a-z A-Z > www shell>> cat www THIS IS A TEST
### 3.去掉不想要的字串
shell>> tr -d this ### 去掉有关 t.e.s.t this
man man test e
### 4.取代字串
shell>> tr -s "this" "TEST" this TEST th TE
指令:clear 用途:清除萤幕用。
使用方法:在 console 上输入 clear。
名称: reset, tset 使用方法: tset [-IQqrs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]
使用说明:
reset 其实和 tset 是一同个命令,它的用途是设定终端机的状态。一般而言,这个命令会自动的从环境变数、命令列或是其它的组态档决定目前终端机的型态。如果指定型态是 ? 的话,这个程式会要求使用者输入终端机的型别。
由于这个程式会将终端机设回原始的状态,除了在 login 时使用外,当系统终端机因为程式不正常执行而进入一些奇怪的状态时,你也可以用它来重设终端机o 例如不小心把二进位档用 cat 指令进到终端机,常会有终端机不再回应键盘输入,或是回应一些奇怪字元的问题。此时就可以用 reset 将终端机回复至原始状态。选项说明:
-p 将终端机类别显示在萤幕上,但不做设定的动作。这个命令可以用来取得目前终端机的类别。 -e ch 将 erase 字元设成 ch -i ch 将中断字元设成 ch -k ch 将删除一行的字元设成 ch -I 不要做设定的动作,如果没有使用选项 -Q 的话,erase、中断及删除字元的目前值依然会送到萤幕上。 -Q 不要显示 erase、中断及删除字元的值到萤幕上。 -r 将终端机类别印在萤幕上。 -s 将设定 TERM 用的命令用字串的型式送到终端机中,通常在 .login 或 .profile 中用 范例: 让使用者输入一个终端机型别并将终端机设到该型别的预设状态。 # reset ?
将 erase 字元设定 control-h # reset -e ^B
将设定用的字串显示在萤幕上 # reset -s Erase is control-B (^B). Kill is control-U (^U). Interrupt is control-C (^C). TERM=xterm;
|
|
|
|
[ 收藏]
[ 推荐]
[ 评论(0条)]
[返回顶部] [打印本页]
[关闭窗口] |
|
|
| |
|
|
|