shell文本处理1
~$ cat test.txt1
x xy > xyy > xyy > xyxyxy > a > c > ~$ let value=`cat test.txt | tr -d '>' | tr -d ' ' | tee file.tmp| wc -l `-1 ; head -n $value file.tmp > test.txt1; rm file.tmp ~$ cat test.txt1 x xy xyy xyy xyxyxy a c
对文本test.txt1进行处理
去除>符号 去除' '空格 然后存入源文件
注意点:
(1)let 可以进行数值运算
(2)重定向回源文件需要使用中间文件
(3)工具集合: tr tee wc
(4) tr 中 ' ' = ‘\040’