Results 1 to 1 of 1
Hi,
I have lines in some files that look exactly as below, and the line numbers they occur in are always the same. (Lines 136-139)
W 0.00000000 0.00000000 2.00000000
W ...
- 05-25-2010 #1Just Joined!
- Join Date
- May 2010
- Posts
- 4
Replacing numbers in bash scripts
Hi,
I have lines in some files that look exactly as below, and the line numbers they occur in are always the same. (Lines 136-139)
W 0.00000000 0.00000000 2.00000000
W 0.50000000 0.50000000 2.50000000
W 0.00000000 0.00000000 3.00000000
W 0.50000000 0.50000000 3.50000000
I'd like to replace the last number in each row for each file by numbers related to the variable $vacheight, so that the median of these 4 numbers is always half of $vacheight.
The files are all named "run_example", but are in different folders named "examples#" where # is a number from 140 to 199.
As a related example, Line 117 reads:
Below is the relevant section of code that works for Line 117 and increments the number on Line 117 by 0.1 each time, in a different folder.Code:celldm(3) = 5.000,
Thank you very much for your help!Code:vacheight=`expr 4.500` for i in */run_example; do printf '117s/= [^,]*/= %s/\nwq\n' "$vacheight" | ed -s "$i" vacheight=$(echo "scale=3; $vacheight + 0.100" | bc) done


Reply With Quote