I have some data with the following format:
2 1 500 500 500
3 1 500 500 500
6 1 500 500 500
8 1 500 500 500
9 1 500 500 500
11 1 500 500 500
12 1 500 500 500
14 1 500 500 500
15 1 500 500 500
16 1 500 500 500
17 1 500 500 500
20 1 500 500 500
21 1 500 500 500
23 1 500 500 500
24 1 500 500 500
25 1 500 500 500
27 1 500 500 500
30 1 500 500 500
31 1 500 500 500
32 1 500 500 500
33 1 500 500 500
34 1 500 500 500
35 1 500 500 500
38 1 500 500 500
40 1 500 500 500
41 1 500 500 500
43 1 500 500 500
44 1 500 500 500
46 1 500 500 500
47 1 500 500 500
I want to change the 500 values to 100 only in the lines in which the 1st column equal from 11-40. For now I'm doing something like:
Numbers=($(seq 11 1 40))
File=filename.txt
for i in ${Numbers[*]}
do
if [ $i == awk '{print $1}' $File ];then
NumberLine=$(grep -n $i $File | cut -d : -f 1)
sed -i "${NumberLine}s/500/100/" $File
fi
done
Individually, each line seems to do what I want to do, but when I put them in them in the loop, I get the following error:
./changeRestraints.sh: line 5: [: too many arguments
I suspect that this has to do with my awk as a part of my conditional statement. How can I fix this to make this script run?
Thank you,
Numbers=($(seq 11 1 40))is not doing what you expect it to do. It currently assigns the value11toNumbers. You should change this to:Numbers=$(seq 11 1 40).