How do I clear only 5 gold nuggets insted of all?

Solution 1:

The syntax (in 1.11) is

clear [player] [item] [data] [maxCount] [dataTag]

So in your case it will be

clear @p gold_nugget 0 5

The Minecraft Gamepedia wiki is a good place to start when learning the syntax of commands.