|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello all
Have the following problem, can someone please . I need to do this in a Unix Shell script. I have a text file with the following two lines in the file; Audit_Value_1: 10000 Audit_Value_2: 5764.34 The followng should happen: 1. Read values 2. calc new values; x=10000-1 y=5764.34 - 2.4 3.Replace original lines in file with; Audit_Value_1: 9999 Audit_Value_2: 5761.94 Your would be appreciated. Thanks, B |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
bcpkh wrote:
> Hello all > > Have the following problem, can someone please . I need to do this > in a Unix Shell script. > > I have a text file with the following two lines in the file; > > Audit_Value_1: 10000 > Audit_Value_2: 5764.34 > > The followng should happen: > 1. Read values > > 2. calc new values; > x=10000-1 > y=5764.34 - 2.4 > > 3.Replace original lines in file with; > Audit_Value_1: 9999 > Audit_Value_2: 5761.94 I think you mean "Replace original lines in file with calculated values" (otherwise you don't need step 2 if you just want to replace them by a constant string). > > Your would be appreciated. awk ' $1 == "Audit_Value_1:" { $2 -= 1 } $1 == "Audit_Value_2:" { $2 -= 2.4 } { print } ' your_text_file Janis > > Thanks, > > B > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
bcpkh wrote:
> Hello all > > Have the following problem, can someone please . I need to do this > in a Unix Shell script. > > I have a text file with the following two lines in the file; > > Audit_Value_1: 10000 > Audit_Value_2: 5764.34 > > The followng should happen: > 1. Read values > > 2. calc new values; > x=10000-1 > y=5764.34 - 2.4 > > 3.Replace original lines in file with; > Audit_Value_1: 9999 > Audit_Value_2: 5761.94 I think you mean "Replace original lines in file with calculated values" (otherwise you don't need step 2 if you just want to replace them by a constant string). > > Your would be appreciated. awk ' $1 == "Audit_Value_1:" { $2 -= 1 } $1 == "Audit_Value_2:" { $2 -= 2.4 } { print } ' your_text_file Janis > > Thanks, > > B > |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Jul 22, 1:54 pm, Janis Papanagnou <Janis_Papanag...@hotmail.com>
wrote: > bcpkh wrote: > > Hello all > > > Have the following problem, can someone please . I need to do this > > in a Unix Shell script. > > > I have a text file with the following two lines in the file; > > > Audit_Value_1: 10000 > > Audit_Value_2: 5764.34 > > > The followng should happen: > > 1. Read values > > > 2. calc new values; > > x=10000-1 > > y=5764.34 - 2.4 > > > 3.Replace original lines in file with; > > Audit_Value_1: 9999 > > Audit_Value_2: 5761.94 > > I think you mean "Replace original lines in file with calculated values" > (otherwise you don't need step 2 if you just want to replace them by a > constant string). > > > > > Your would be appreciated. > > awk ' > $1 == "Audit_Value_1:" { $2 -= 1 } > $1 == "Audit_Value_2:" { $2 -= 2.4 } > { print } > ' your_text_file > > Janis > > > > > > > Thanks, > > > B- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - Hello Janis 'Replace original lines in file with calculated values' is indeed exactly what I meant and thanks for the advice! B |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Jul 22, 1:54 pm, Janis Papanagnou <Janis_Papanag...@hotmail.com>
wrote: > bcpkh wrote: > > Hello all > > > Have the following problem, can someone please . I need to do this > > in a Unix Shell script. > > > I have a text file with the following two lines in the file; > > > Audit_Value_1: 10000 > > Audit_Value_2: 5764.34 > > > The followng should happen: > > 1. Read values > > > 2. calc new values; > > x=10000-1 > > y=5764.34 - 2.4 > > > 3.Replace original lines in file with; > > Audit_Value_1: 9999 > > Audit_Value_2: 5761.94 > > I think you mean "Replace original lines in file with calculated values" > (otherwise you don't need step 2 if you just want to replace them by a > constant string). > > > > > Your would be appreciated. > > awk ' > $1 == "Audit_Value_1:" { $2 -= 1 } > $1 == "Audit_Value_2:" { $2 -= 2.4 } > { print } > ' your_text_file > > Janis > > > > > > > Thanks, > > > B- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - Hello Janis 'Replace original lines in file with calculated values' is indeed exactly what I meant and thanks for the advice! B |
|
![]() |
| Outils de la discussion | |
|
|