Most useful Linux commands to solve daily tasks. ND#1

Today as usual was doing some random stuff. Below the list of my queries, commands and sources there I found solution.

1. Find all unique file extensions in folder. The advantage is it almost doesn’t have dependencies.

find . -type f | rev | cut -d. -f1 | rev  | tr '[:upper:]' '[:lower:]' | sort | uniq -c | sort -rn

I replaced parameter —count by -c of uniq command due to lack of full name option in my version of Linux. Source is https://stackoverflow.com/a/55317141/3012494

2. Move out files with concrete extension (or pattern) to another folder. For example i separated PDF fildes from images in my download folder

rsync -rv --include '*/' --include '*.pdf' --exclude '*' --prune-empty-dirs --remove-source-files --progress Source/ Target/

I combined different parameters here to actually move files out and cleanup empty directories at the same time. Source is https://unix.stackexchange.com/a/230536/581616

3. Package manager to use most commands as it should be in modern versions on Asustor NAS

1. Install Entware 1.0 from Asustor App Central
2. From SSH console session to the NAS:
opkg update && opkg upgrade
opkg install bash
3. sudo echo /bin/ln -s /opt/bin/bash /bin/bash > /usr/local/etc/init.d/S76bash.sh

Source forum topic https://emby.media/community/index.php?/topic/96972-install-bash-script-interpreter-on-asustor-for-use-with-scripterx/

Leave a Reply

Your email address will not be published. Required fields are marked *

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.