本帖最后由 Gin_Q 于 2020-3-21 15:12 编辑
我对shell了解不多,你应该多学学linux三剑客
排序文本最后一次匹配到的数据- #!/bin/bash
- rm -f result.txt result1.txt 2>/dev/null
- for a in `ls *.txt`
- do
- for b in `grep -o -E "[[:space:]]{2}-[0-9]{1,12}.[0-9]{1,12}[[:space:]]{2}" $a`
- do
- temp=$b
- done
- echo $temp |awk -v fname=$a '{printf "%s %s\n",fname,$1}' 1>>result1.txt
- done
- sort -nr -t ' ' -k 2 result1.txt 1>result.txt
- rm -f result1.txt
-
- #grep -o -E "[[:space:]]{2}-[0-9]{1,12}.[0-9]{1,12}[[:space:]]{2}" $a | tac n 1 |awk -v fname=$a '{printf "%s %s\n",fname,$1}' 1>>result1.txt
复制代码
- cccc.txt -23.8882046924
- dddd.txt -65.8839646924
- bbbb.txt -268.882046924
- aaaa.txt -2603.82046924
复制代码
|