I've added a bunch of files via ipfs add
. How do I unpin and remove all of these at once?
Asked
Active
Viewed 1.4k times
3 Answers
52
to unpin all added content:
ipfs pin ls --type recursive | cut -d' ' -f1 | xargs -n1 ipfs pin rm
then optionally run storage garbage collection to actually remove things:
ipfs repo gc
-
7`ipfs pin ls -q --type recursive -q | xargs ipfs pin rm` seems to work for me. `-n1` would make one instance of ipfs for each pin, pretty slow. – Mitar Mar 13 '18 at 23:21
-
4There is a mistake with the repeated -q flag here. Otherwise it works nicely. – Jeff Jul 17 '18 at 11:47
-
2`ipfs pin rm $(ipfs pin ls -q --type recursive)` also works – protometa Apr 09 '19 at 22:57
-
1@protometa your method there runs the risk of creating a command too long for the shell to execute. – Daniel Jun 17 '19 at 08:32
-
Seems like when I do: `du -sh .ipfs` its size still remain same – alper Jan 01 '22 at 13:27
-
I'm running Windows 10 and protometa's answer worked for me. – JDOaktown Jan 22 '22 at 01:18
2
Additionally to jclay's answer, you might also want to delete everything on MFS:
ipfs files ls / | while read f; do ipfs files rm -r "/$f"; done
(Obligatory warning that this won't work if paths contain newlines.)

Caesar
- 6,733
- 4
- 38
- 44
-
1I needed to add a slash in the filename like: ```ipfs files ls / | while read f; do ipfs files rm -r "/$f"; done``` – splch May 26 '21 at 20:30
0
Based on Daniel's answer, here's how to do it in a Docker container
docker exec ipfs_container_name ipfs pin ls --type recursive | cut -d' ' -f1 | xargs -n1 docker exec ipfs_container_name ipfs pin rm
Replace ipfs_container_name
with the name of your docker container.

esot321c
- 1
- 1