|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I have a script output file that looks like device date size free - -- -------------- ----- ----- ----- RAW01 Nov122005 120g 102g RAW02 NOV122005 120g 102g I would like to just filter out the 3rd column(size) and then add the values (or it can be more as well). So it should be 120 + 120 = 240. Based on how this value is divisible by 5, I want to write more case statements. Could you me how to just strip the 3rd column and add the values in a Korn shell script. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
asiadbajobs@gmail.com wrote:
> Hi, > > I have a script output file that looks like > device date size free > - -- -------------- ----- ----- ----- > RAW01 Nov122005 120g 102g > RAW02 NOV122005 120g 102g > > I would like to just filter out the 3rd column(size) and then add the > values (or it can be more as well). So it should be > 120 + 120 = 240. Based on how this value is divisible by 5, I want to > write more case statements. > > Could you me how to just strip the 3rd column and add the values > in a Korn shell script. > shell is an environment you use to call tools, it's rarely the best choice for writing text processing scripts. In this case, it's trivial in awk: awk '{tot += $3}END{print (tot%5 ? "not " : "") "divisible by 5"}' file Regards, Ed. |
|
![]() |
| Outils de la discussion | |
|
|