Minecraft wiki entry for item, associated text: To replace the items in the bottom-right slot of a single chest two block above with four spruce saplings:
/item replace block ~ ~2 ~ container.26 with minecraft:spruce_sapling 4
To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings:
/item replace entity @p hotbar.8 with minecraft:spruce_sapling 4
To replace the item in the offhand of the selected player with the item in their main hand:
/item replace entity @s weapon.offhand from entity @s weapon.mainhand
To put a brown banner on a player's head
/item replace entity @s armor.head with minecraft:brown_banner