Cmdline - Bytesized Hosting Wiki

Command Line Tips & 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 ".*/.*sample.*\.\(avi\|mkv\|mp4\|vob\)" ##### Find files in your torrents and nzbget directories that are not linked in your media folder. find ~/media -type l -exec readlink -f {} \; > links.txt && find ~/torrents ~/nzbget -type f > files.txt && 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 {} \; && 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 ".*/.*sample.*\.\(avi\|mkv\|mp4\|vob\)" -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 && 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 ".*/.*sample.*\.\(avi\|mkv\|mp4\|vob\)" -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 {} \; > links.txt && find ~/torrents ~/nzbget -type f > files.txt && grep -Fxv -f links.txt files.txt | xargs -d '\n' rm --- ### Display HDD Usage --- echo -e "\e[33mused $(du -sh ~ | awk -F " " '{print $1}')iB\e[0m"


Last Author Contributors Versions Last update
Pete 22 Mon, 06 Jan 2025 07:25:24 +0100