# Finding distfiles one may not need to keep, for deletion.



## jb_fvwm2 (Nov 11, 2011)

Some may keep distfiles in /usr/ports/distfiles, say if a port has a minor version bump and one does not wish to re-dowload.  However, there may be
Thisport-1.gz
Thisport-2.gz etc which were inadvertantly left behind, say by an interrupted
portmaster run or equivalent.

```
# only've tried it with [port]gnuls[/port]
cd [FILE]/usr/ports/distfiles[/FILE]
gnuls -R "*.Z" "*.zip" "*.bz2" "*.gz" "*.tgz" -1 | sort | tee -a [FILE]/tmp/fil.1[/FILE]
tr -d "[:digit:]"  <  [FILE]fil.1[/FILE]  > [FILE]fil.2[/FILE]
cat [FILE]fil.2[/FILE] | uniq -d
```
If one is fortunate, only a few extra files  to delete will be shown by the last command in the sequence, and one's shell (if configured to)  can complete the filenames as one deletes the duplicates.
[I discovered the gnuls part previously, but only very recently the freebsd-questions list mentioned the tr command.]
.....
Not quite yet able to use the suggestions below as I've many .dat, subdirectories (etc) in /usr/ports/distfiles from the days I saved every other file there, comments, coding tests etc. ( .. and busy at the moment with other configuration tasks...)


----------



## SirDice (Nov 11, 2011)

If you have portmaster(8) installed:
`# portmaster --cleandistfiles`

If you have portupgrade(8) installed:
`# portsclean --distclean`


----------



## wblock@ (Nov 11, 2011)

SirDice said:
			
		

> If you have portmaster(8) installed:
> `# portmaster --cleandistfiles`



Needs one more dash: --clean-distfiles.  Run without options, it removes old distfiles for any installed port.  To get rid of all outdated distfiles, add -t.  It can take a while.  Add -y to automatically answer yes to the "Are you really, really, ultra-triple-sure you want to remove this file?" questions.
`# portmaster -t -y --clean-distfiles`


----------



## SirDice (Nov 11, 2011)

wblock@ said:
			
		

> Needs one more dash: --clean-distfiles.


Oops. Did that one from the top of my head :r


----------

