查找和删除UNIX(更新版) [英] Find and remove in unix(Updated)
本文介绍了查找和删除UNIX(更新版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的输入文件:
sample.txt的
:
3"
6-position
7' 4" to 10' 3-1/2"
4.8"
Adjustable from 99" to 111" - max 148
和输出我只需要3,即
output.txt的
:
3
4.8
所以基本上我需要打印的符号的数值,其他非数字文本需要被完全删除。
So basically I need to print the numeric value for the "
symbol, other non-numeric text needs to be removed entirely.
我试着用 SED
来实现这一点,但我没能得到期望的结果。
I tried to implement this with sed
, but I was not able to get the desired result.
有没有办法实现这个UNIX上?
Is there any way to achieve this on UNIX?
推荐答案
AWK更适合执行这类任务:
awk is more suited to perform this type of task:
awk '/^ *[0-9]*(\.[0-9]+)?" *$/{sub(/"/, ""); print}' inFile
OUTPUT:
3
4.8
这篇关于查找和删除UNIX(更新版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文