论文遇到了瓶颈,歇一歇,没用awk完成,纯粹是休息下……
tr [OPTION] SET1 [SET2] file
说明:
tr -s SET1 file :对于给定的文段,将凡在SET1中的出现的连续的字符都压缩成一个字符。
echo "abaa ddxx gg" | tr -s 'a dxg' 结果:aba dx g
tr -d SET1 file :对于给定的文段,删除所有在SET1中出现的字符。
tr -t SET1 SET2 file : 将SET1 截断成SET2长度,然后依SET1和SET2中字符出现的次序依次做替换。
ls -l *media* | tr -s ' ' | cut -d ' ' -f 9
tr -c SET1 [SET2] file : 对于给定的文段,对SET1的补集做操作,一般同其它选项结合使用。
SETs是指定的字符(串),可以转换的字符如下:
NNN character with octal value NNN (1 to 3 octal digits) \ backslash a audible BEL backspace f form feed new line return horizontal tab v vertical tab
CHAR1-CHAR2 all characters from CHAR1 to CHAR2 in ascending(升序) order [CHAR*] in SET2, copies of CHAR until length of SET1 [CHAR*REPEAT] REPEAT copies of CHAR, REPEAT octal if starting with 0 [:alnum:] all letters and digits [:alpha:] all letters [:blank:] all horizontal whitespace [:cntrl:] all control characters [:digit:] all digits [:graph:] all printable characters, not including space [:lower:] all lower case letters [:print:] all printable characters, including space [:punct:] all punctuation characters [:space:] all horizontal or vertical whitespace [:upper:] all upper case letters [:xdigit:] all hexadecimal digits [=CHAR=] all characters which are equivalent to CHAR
将多个空格转成一个空格:
1、用awk:
awk '{print $2}' file
2、一定要用cut的话:
cat file|tr -s ' '|cut -d' ' -f2