指令大全 - Linux 指令篇:字串处理--tr
指令大全-Linux指令篇:字串处理--tr
名称:tr
###1.比方说要把目录下所有的大写档名换为小写档名?
似乎有很多方式,"tr"是其中一种:
#!/bin/sh
dir="/tmp/testdir";
files=`find$dir-typef`;
foriin$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.自己试验中...lowercasetouppercase
trabcdef...[del]ABCDE...[del]
tra-zA-Z
tr'[:lower:]''[:upper:]'
shell>>echo"thisisatest"|tra-zA-Z>www
shell>>catwww
THISISATEST
###3.去掉不想要的字串
shell>>tr-dthis###去掉有关t.e.s.t
this
man
man
test
e
###4.取代字串
shell>>tr-s"this""TEST"
this
TEST
th
TE
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20