I have a bunch of files, all of them in the same directory, with names opening1.py
, opening2.py
... and all of them have line(s) with 'steps': [6]} ],
. What I want to do is to replace 6
by a 9
. I have been trying the solution here: How to grep and replace
with a command like this one:
grep -rl "'steps': [6]} ]," opening* | xargs sed -i "s/'steps': [6]} ],/'steps': [9]} ],/g"
but it doesn't work. It says sed: no input files
. I don't know if the problem is due to the presence of spaces in the string or ticks '
. How can I do it?
Thanks.
P. S.: In case it may help: files opening...
are quite big. The string I'm searching is inside a for loop, also a big and apparently horrible one like this:
for num in range(4):
date_c = date_in
while date_c <= date_in:
lat = coordinates[num][0]
lon = coordinates[num][1]
df1 = gat.select_grib_df(inputfile,
{'indicatorOfParameter': 11},
[ {'coord': (lat, lon)],
'date': date_c,
'steps': [6]} ],
['indicatorOfParameter', 'dataDate', 'dataTime', 'step'])
and I want that to be exactly like before but with 9 in steps
instead of 6: Note: sometimes the number in indicatorOfParameter
can change.
for num in range(4):
date_c = date_in
while date_c <= date_in:
lat = coordinates[num][0]
lon = coordinates[num][1]
df1 = gat.select_grib_df(inputfile,
{'indicatorOfParameter': 11},
[ {'coord': (lat, lon)],
'date': date_c,
'steps': [9]} ],
['indicatorOfParameter', 'dataDate', 'dataTime', 'step'])
the only change is the number 6 per 9 in the line with the word steps
.