由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Help: How to extract the numberic value in a sentence?
相关主题
c++ class design issue[合集] 【求助】如何将c string中的string转换成int?谢谢
请教改numpy array的dtype[合集] Python下面如何进行numeric analysis and statistical analysis
SQL fast search in a 10 million records table (转载)我的DBA在生成ORACLE table的时候需要一个一个column看 (转载)
简单算法问题some problems with "cin"
How to sort a map in C++ STL based on Value, instead of KeyC++ Q14: unnamed namespace
一个SQL的题目经典题atoi的溢出处理 (转载)
教授的问题(C language)A problem on string parsing (using either grep or perl)
有人能解释一下这段C++代码吗看了那个招聘的帖子,自觉需要把 atoi温习一下。赶紧的
相关话题的讨论汇总
话题: value话题: numberic话题: sentence话题: extract话题: awk
进入Programming版参与讨论
1 (共1页)
s*******f
发帖数: 757
1
Can someone help me out on this? I have a executable c program that will
give a sentence like this:
Quantization error of era_adv_jfm/era_tot_adv_high with map era_adv_jfm/high
.map is 860.665649 per sample (632 samples)
What I need is the first numeric value so that I can use it in a schell
script.
Thanks.
p*u
发帖数: 2454
2
don't understand what u want to do, but to get a numeric value out of a
string is easy, just parse it and use isdigit() to check on each char

high

【在 s*******f 的大作中提到】
: Can someone help me out on this? I have a executable c program that will
: give a sentence like this:
: Quantization error of era_adv_jfm/era_tot_adv_high with map era_adv_jfm/high
: .map is 860.665649 per sample (632 samples)
: What I need is the first numeric value so that I can use it in a schell
: script.
: Thanks.

s*******f
发帖数: 757
3
Can you be more specific? I am really a newbie about shell script. I stored
the output sentence into a file and now I ONLY need to know the value of the
numeric part. Thanks again.

【在 p*u 的大作中提到】
: don't understand what u want to do, but to get a numeric value out of a
: string is easy, just parse it and use isdigit() to check on each char
:
: high

t****t
发帖数: 6806
4
上perl

stored
the

【在 s*******f 的大作中提到】
: Can you be more specific? I am really a newbie about shell script. I stored
: the output sentence into a file and now I ONLY need to know the value of the
: numeric part. Thanks again.

g******o
发帖数: 143
5
用perl,一切都能搞定
要不用awk,如果数字位置固定
awk '{print $9}' < input

high

【在 s*******f 的大作中提到】
: Can someone help me out on this? I have a executable c program that will
: give a sentence like this:
: Quantization error of era_adv_jfm/era_tot_adv_high with map era_adv_jfm/high
: .map is 860.665649 per sample (632 samples)
: What I need is the first numeric value so that I can use it in a schell
: script.
: Thanks.

s*******f
发帖数: 757
6
I was able to use awk for it. Thanks everyone.

【在 g******o 的大作中提到】
: 用perl,一切都能搞定
: 要不用awk,如果数字位置固定
: awk '{print $9}' < input
:
: high

s*******f
发帖数: 757
7
I have to bother you guys again, e.g, in my shell script, I want to pass the
numeric value to a variable. I did this:
#!/bin/sh
...
value = `awk '{print $column} < input `
...
It seems there is something wrong with this, when I used echo to test the
passing, the result from awk is not passed to value. Could someone tell me
what was wrong in the statement. Thanks again.

【在 g******o 的大作中提到】
: 用perl,一切都能搞定
: 要不用awk,如果数字位置固定
: awk '{print $9}' < input
:
: high

t*********s
发帖数: 5
8
what shell, (t)csh or bash ...

the
$column in shell is different from $column in awk
for bash(no space allowed around the '='):
value=$( awk -v col=$column '{ print $col }' < input )

【在 s*******f 的大作中提到】
: I have to bother you guys again, e.g, in my shell script, I want to pass the
: numeric value to a variable. I did this:
: #!/bin/sh
: ...
: value = `awk '{print $column} < input `
: ...
: It seems there is something wrong with this, when I used echo to test the
: passing, the result from awk is not passed to value. Could someone tell me
: what was wrong in the statement. Thanks again.

s*******f
发帖数: 757
9
Yeah, that is the issue. Thanks a lot.

【在 t*********s 的大作中提到】
: what shell, (t)csh or bash ...
:
: the
: $column in shell is different from $column in awk
: for bash(no space allowed around the '='):
: value=$( awk -v col=$column '{ print $col }' < input )

S*****n
发帖数: 227
10
还可以写个tokenizer. heihei.

【在 t****t 的大作中提到】
: 上perl
:
: stored
: the

1 (共1页)
进入Programming版参与讨论
相关主题
看了那个招聘的帖子,自觉需要把 atoi温习一下。赶紧的How to sort a map in C++ STL based on Value, instead of Key
Re: 请教 Python 如何去掉json文件里数字上的双引号?一个SQL的题目
fork(): why both if and else are executed?教授的问题(C language)
GO似乎是目前最难反编译的代码了有人能解释一下这段C++代码吗
c++ class design issue[合集] 【求助】如何将c string中的string转换成int?谢谢
请教改numpy array的dtype[合集] Python下面如何进行numeric analysis and statistical analysis
SQL fast search in a 10 million records table (转载)我的DBA在生成ORACLE table的时候需要一个一个column看 (转载)
简单算法问题some problems with "cin"
相关话题的讨论汇总
话题: value话题: numberic话题: sentence话题: extract话题: awk