The /fill
command implicitly splits syntax depending on whether the block you're filling in is a tile entity (blocks that hold extra data like chests, furnaces, or beacons). If you're not filling in a tile entity, you have the option to replace only certain blocks, e.g. /fill ~ ~ ~ ~3 ~3 ~3 stone 0 replace grass
will only remove grass.
You're filling in command blocks, which are tile entities. Because of this (note that it's working as intended), you can only specify NBT after the replace
argument, and don't have the option to replace only certain blocks.
So essentially, you can fill in a bunch of command blocks containing that command, but you can't only replace certain blocks while you do so. To do this, simply remove the second command_block
from your command like so:
/fill 607.5 12 981.5 589.5 12 939.5 command_block 0 replace {Command:"/summon Item ~ ~-8 ~ {Item:{id:iron_nugget,Count:1}}"}