|
Blue Forest http://www.lslnet.com at 11:18 on June 26, 2006
Will the shell how Addendum I have a document which reads as follows :
Itm=701
Cal=2100
&L
Itm=702
Cal=2200
&L
Itm=703
Cal=2300
&L
----
Wish to be allocated a shell, to require compliance with the conditions itm=701 itm=703 cal value and the combined value cal how compiled? |
Will the shell how Addendum [code]
#!/bin/sh
A=`sed n '/itm=701/=' filename`
B=`sed n '/itm=701/=' filename`
701a=`expr ${a} + 1`
703b=`expr ${b} + 1`
701cal=`sed n "${701a}" p |sed's' /^cal=\ ([0-9]\{1, \}\) /\1/ ' `
703cal=`sed n "${703b}" p |sed's' /^cal=\ ([0-9]\{1, \}\) /\1/ ' `
Total=`expr ${701cal} + ${703cal}`
Echo $total
[/code]
I do not have the environment. . . . I do not know whether there are problems. . . Fan speak of a point, I felt strange. . . : Oops : |
Will the shell how Addendum [code]#!/usr/bin/bash
Sed-n 's/.*=\ ([0-9]*\) /\1/g;p' filename |\
Awk 'BEGIN{
RS= "&L";
}{
A[$1]=$2;
}END{
Print a[701]+a[703]} '[/code]
Can I do not know where this |
Will the shell how Addendum [code]awk -F= '$ 2==701||$2==703{getline;a+=$2}END{print a}' datafile[/code] |
Will the shell how Addendum Riding a fixed sentence on the main version is too serious a concise |
Will the shell how Addendum
| |
|