Cmdline - Bytesized Hosting Wiki

Command Line Tips &amp Tricks


Finding Things


Find broken symbolic links in your media directory.

find ~/media -xtype l

Find empty sub-directories in your media directory.

find ~/media -type d -empty

Find sample movie files (contains sample in name) by size (less than 50MB) and extension (avi,mkv,mp4,vob)

find ~/torrents ~/nzbget -type f -size -51200k -regex &quot.*/.*sample.*\.\(avi\|mkv\|mp4\|vob\)&quot

Find files in your torrents and nzbget directories that are not linked in your media folder.

find ~/media -type l -exec readlink -f {} \ &gt links.txt &amp&amp find ~/torrents ~/nzbget -type f &gt files.txt &amp&amp grep -Fxv -f links.txt files.txt


Finding and Deleting Things


With Confirmation - Interactive Removal (Y/N) For each file

Find and remove broken symbolic links in your media directory.

find ~/media -xtype l -exec rm -i {} \

Find and remove broken symbolic links then remove any empty sub-directory in your media directory.

Warning: Confirmation only exists for the broken symbolic links empty folders are removed without confirmation.
find ~/media -xtype l -exec rm -i {} \ &amp&amp find ~/media -type d -empty -delete

Find sample movie files (contains sample in name) by size (less than 50MB) and extension (avi,mkv,mp4,vob) and delete them.

find ~/torrents ~/nzbget -type f -size -51200k -regex &quot.*/.*sample.*\.\(avi\|mkv\|mp4\|vob\)&quot -exec rm -i {} \


Without Confirmation

Find and remove broken symbolic links in your media directory.

find ~/media -xtype l -delete

Find and remove empty sub-directories in your media directory.

find ~/media -type d -empty -delete

Find and remove broken symbolic links then remove any empty sub-directory in your media directory.

find ~/media -xtype l -delete &amp&amp find ~/media -type d -empty -delete

Find sample movie files (contains sample in name) by size (less than 50MB) and extension (avi,mkv,mp4,vob) and delete them.

find ~/torrents ~/nzbget -type f -size -51200k -regex &quot.*/.*sample.*\.\(avi\|mkv\|mp4\|vob\)&quot -delete

Find and remove files in your torrents and nzbget directories that are not linked in your media folder.

find ~/media -type l -exec readlink -f {} \ &gt links.txt &amp&amp find ~/torrents ~/nzbget -type f &gt files.txt &amp&amp grep -Fxv -f links.txt files.txt | xargs -d &#39\n&#39 rm


Display HDD Usage


echo -e &quot\e[33mused $(du -sh ~ | awk -F &quot &quot &#39{print $1}&#39)iB\e[0m&quot


Last Author Contributors Versions Last update
Pete 24 Wed, 16 Apr 2025 10:45:39 +0200