以下以小写转大写为例
(1)sed:
cat file | sed 'y/abcdefghijklmnopqrstuvwxyz/
(2)tr:
cat file | tr a-z A-Z
cat file | tr "[:lower:]" "[:upper:]"
(3)perl:
$string="abcdef";
$string =~ tr/[a-z]/[A-Z]/;
or
$string=uc($string); #大小转小写用lc,具体参见perldoc -f lc与perdoc -f uc
"以下以小写转大写为例 (1)sed: cat file | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' (2)tr: cat file | tr a-z A-Z cat file | tr "[:lower:]" "[:upper:]" (3)perl: $string="abcdef"; $string =~ tr/[a-z]/[A-Z]/; or $string=uc($string); #大小转小写用lc,具体参见perldoc -f lc与perdoc -f uc"
- Linux下大小写转换的方法小结 - TIPs - 冷月无声 (在「Google 網頁註解」中檢視)
No comments:
Post a Comment