Hi guys, i have an executable file that contains several records and fields. One of the records has a variable filed that must be changed each time i want to execute the file. Would it be possible that i can use a loop to change the value of that field? Suppose that the field address is:
Record number 40, field number 10
and the value of that field must be changed between 0.01 to 1.0 by step 0.01
Post an example of your input and your expected output. Use code tags when doing this.
input(executable file):
LOCSEARCH OCT 20 20 10 0.01 10000 5000 0 1
LOCGRID 500 500 40 -300 -300 0 1.0 1.0 1.0 PROB_DENSITY SAVE
LOCMETH EDT_OT_WT 9999.0 4 -1 -1 -1.68 -6 -1.0 1
#LOCMETH GAU_ANALYTIC 9999.0 4 -1 -1 -1.68 6
LOCGAU 0.2 0.0
LOCGAU2 0.01 0.01 5.0
I want to change 2nd field in the record which start with "LOCGAU2" (here is the last record) and as i said before with theses ranges: from 0.01 to 1.0 by step 0.01. It means i have to repeat execution in 100 times, but if i can use a loop that can change that value (2nd field of last record) there is no need for long reparations manually and each time that the loop changes that value, the input will be run with new value for "LOCGAU2" parameter (2nd field of that record) .
Still don't know how this incrementing should look like. Do you want as many output files as you have cycles to increment until that value hits 1.0 or do you want just output where the special line is in or... Here is a try:
$ awk '/^LOCGAU2/ {print; while($2 <= 1){$2+=0.01; $2=sprintf("%01.2f", $2); print}}' infile
LOCGAU2 0.01 0.01 5.0
LOCGAU2 0.02 0.01 5.0
LOCGAU2 0.03 0.01 5.0
LOCGAU2 0.04 0.01 5.0
LOCGAU2 0.05 0.01 5.0
... shortened ...
LOCGAU2 0.94 0.01 5.0
LOCGAU2 0.95 0.01 5.0
LOCGAU2 0.96 0.01 5.0
LOCGAU2 0.97 0.01 5.0
LOCGAU2 0.98 0.01 5.0
LOCGAU2 0.99 0.01 5.0
LOCGAU2 1.00 0.01 5.0
Actually i wrote a script just like below:
#!/bin/bash
rm -r ./gmt/*
rm -r ./loc/*
rm -r ./results/*
rm -r ./time/*
Vel2Grid run_7VM_p
Grid2Time run_7VM_p
Grid2Time run_7VM_s
Time2EQ run_7VM_p
for i in {1..7}
do
rm -r ./model/*.*
rm -r ./time/*.*
Vel2Grid run_${i}p
Grid2Time run_${i}p
Grid2Time run_${i}s
NLLoc run_${i}p
done
./result
./statics
#./ploteq
#./ps2jpg
Each time I run this file the script read some files such as �[/SIZE][/FONT][COLOR=black][FONT=Verdana]run_7VM_p� which contains inputs that I show in last session, I want to run this script for 100 times and each time it must run with different �run_7VM_p� file. The change in this file means the change in a record of that file which starts with �LOCGAU2� and then change 2nd field of that record from 0.01 to 1 by step 0.01. so each time the script run, the value of the 2nd field of that record sake of the �run_7VM_p� file will be changed and then run.
Where do you get these run_7VM_p filenames? It can be looped, for sure, but it has to get the names from somewhere. Show us instead of telling us 'record x'.
*.* is a DOS thing incidentally. In UNIX that just means "any files or folders with . in their name somewhere".