a simple workaround to avoid additional configuration files is to place the configuration somewhere in your script.
# 15x13 ## VxH RATIO #OK # 15x13 ## VxH RATIO #OK # 16x14 ## VxH RATIO #OK # 16x14 ## VxH RATIO #OK # 17x15 ## Vx#H RATIO # # 18x16 ## Vx#H RATIO # # 20x17 ## VxH RATIO #OK # 21x18 ## VxH RATIO #OK # 22x19 ## VxH RATIO #OK # 23x20 ## VxH RATIO #OK # 25x22 ## VxH RATIO #OK
When executed, the script looks for a expression
(in this case VxH
) in itself ($0
):
sed -n '/VxH/p' $0
Because the expression will also be found in the line where the expression
is defined, you have to prevent this line from showing up.
We do so, by excluding all lines which contain the string sed
from the search result:
sed -n '/sed/!p'
Then we select the appropriate field with cut -d "#" -f 2
and choose one line with rl --count=1
RATIO=`sed -n '/VxH/p' $0 |\ sed -n '/sed/!p' |\ cut -d "#" -f 2 |\ rl --count=1`
To quickly remove configurations, for testing
or anything, just destroy the pattern.
(VxH RATIO
becomes Vx#H RATIO
)
$0
is the name of the script itself,
$!
is its PID,
$#
the number of parameters given with $1
— $9
.