linux 大小写转化
程序员文章站
2022-08-31 09:17:59
(1)sed: cat file | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' (2)tr: cat file | tr a-z A-Z cat file | tr "[:lower:]" "[:upper:]" ( ......
(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