Reputation: 10675
I'm have a bash script that I use to manipulate files on a computation cluster.
The files I am trying to manipulate are of the format:
beadSize=6.25
minBoxSize=2.2
lipids=1200
chargedLipids=60
cations=0
HEAD=0
CHEAD=-2
BODY=2
TAIL=3
ION=-1
RHO_BODY=10
RHO_TAIL=14
tol=1e-10
lb=7.1
FTsize=8
ROUNDS=1000000
ftROUNDS=10
wROUNDS=1000
dt=0.01
alpha=1
transSize=0.15
transSizeZ=0.0
ionsTransSize=2.8
ionsTransSizeZ=2.8
rotateSize=0.18
volSize=8
modSize=0.0
forceFactor=2
kappaCV=0
sysSize=26
zSize=300
iVal=1
split=0
randSeed=580
I call a function inside a loop:
for per in $(seq 70 -5 5); do
for seed in {580..583}; do
for c in {"fs","fd","bfs","bfd"}; do
let count=$count+1
startJob $per $seed $c $count
done
done
done
and the lines I use to manipulate:
let n=$1*12
echo $n
cat trm.dat | sed '/memFile*/d' | sed '/rStart*/d' | sed '/test*/d'| sed 's/modSize=[0-9.]*/modSize=0.0/' | sed 's/chachargedLipids=[0-9]*/chargedLipids="$n"/' | grep char #> propFile.dat
for $per=15
, for example, I expect $n==180
. However when I run the script I see:
180
chargedLipids=120
What am I doing wrong?
Note I have also tried to use:
sed "s/chachargedLipids=[0-9]*/chargedLipids=$n/"
With the same result.
Upvotes: 2
Views: 166
Reputation: 212178
chacharged
!= charged
, and the final sed is doing nothing. With single quotes, you would expect to see the literal text chargedLipids="$n"
in your output if a replacement was being made.
Upvotes: 3