How do I kill a specific dropped item in a specific area? [duplicate]

I need to detect and kill sand (only sand) as an item drop in a specific area. I can detect and kill sand if it’s dropped anywhere using a lengthy command, but it doesn’t include the part where it only kills it in a certain area.

It doesn't matter whether the detection part of the command is within the killing area or not, though it would be preferred.

I'm on Java Version 1.14.4

My current command is: /execute at @e[type=item,nbt={id:”minecraft:sand”}}] run kill @e[type=item,nbt={id:”minecraft:sand”}}]


The dx,dy and dz arguments can be used to specify an area in the selector. Example:

/kill @e[type=item,nbt={Item:{id:"minecraft:sand"}},x=5,y=5,z=5,dx=10,dy=10,dz=10]

^ this command will remove any sand items located between 5,5,5 and 15,15,15

x,y and z are the coordinates of one corner and dx,dy and dz are the width, height and length of the cube area. You can read about these arguments on the wiki https://minecraft.gamepedia.com/Commands in the Selecting targets by volume section.