tr 是按字符做替换、删除、压缩的小工具:tr 'a-z' 'A-Z' <file 一把把小写转大写,tr -d'\r'删掉 Windows 换行符,tr -s' ' 把连续空格压成一个。配合管道用,日志清洗、格式统一不用写脚本。