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
|