首页 > `tr -sc 'A-Za-z' '\012'` 命令含义

`tr -sc 'A-Za-z' '\012'` 命令含义

tr -sc 'A-Za-z' '\012' 是什么意思阿 s和c选项单独用还能明白就一起用有点不理解


tr -cs string1 string2命令中

-c是指取string1中集合的补集(complement the set of values in string1),这里就说取a-zA-Z之外的字符

-s是指在替换完成后将string2的内容压缩到单个字符,加上上一条就是连续的非字母字符压缩到一个'\n'(八进制012 = 10,即ASCII中的line feed)

综上,tr -sc 'A-Za-z' '\012'就是将连续的非字母内容转换成回车,即将单词分行输出。

【热门文章】
【热门文章】