Linux 指令篇:字串处理--tr
来源:互联网 发布:淘宝网宝贝 编辑:程序博客网 时间:2024/06/01 07:47
名称: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
来源:http://www.cngnu.org/technology/c496/87.html
### 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
来源:http://www.cngnu.org/technology/c496/87.html
- Linux 指令篇:字串处理--tr
- Linux 指令篇:字串处理--expr
- 关於字串处理的指令:
- Linux常用指令---tr命令
- Linux指令用之记之-tr
- 字串处理
- linux tr
- linux tr
- linux tr
- linux tr
- linux tr
- linux tr
- tr linux
- Linux下tr命令“字符”处理的实用例子
- Linux下tr命令“字符”处理的实用例子
- Linux下tr命令“字符”处理的实用例子
- linux 字符处理指令 awk
- Linux基本指令之sort、uniq、join、cut、paste、split、tr
- 保护WEB服务器的15个技巧
- Linux 指令篇:工作行程资讯与管理--top
- http information
- 修复主引导扇区(windows、linux)
- Linux 指令篇:字串处理--expr
- Linux 指令篇:字串处理--tr
- 希望高手指导
- 字符检测程序(上) 检测GB2312、BIG5
- Linux 指令篇:终端机管理--clear
- 字符检测程序(下)
- 什么是Web2.0
- Linux 指令篇:终端机管理--reset
- 图片渐变轮换效果
- 字节流编码获取原来这么复杂