2019-01-29

2019-01-13

MySQL - Command line to display a list of all views in a given database


mysql -NBA -h the_host -u user_name -p -D database_name -e "SHOW FULL TABLES IN database_name WHERE TABLE_TYPE LIKE 'VIEW';"


Cleaner, only 1 column:

mysql -NBA -h the_host -u user_name -p -D database_name -e "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_TYPE LIKE 'VIEW' AND TABLE_SCHEMA LIKE 'database_name';"

MySQL - Command line to display a list of all tables


mysql -NBA -h the_host -u user_name -p -D database_name -e 'show tables'

2018-11-23

MacOS - How to list the number of files on sub-directories, recursively (command line)

find . -type d -print0 | while read -d '' -r dir; do
    files=("$dir"/*)
    printf "%5d file count for directory %s\n" "${#files[@]}" "$dir"
done

Credits: https://stackoverflow.com/questions/15216370/how-to-count-number-of-files-in-each-directory

MacOS - How to count the number of files in a given directory (command line)

find "/Path/Directory Name" -type f | wc -l

MacOS - How to remove a folder (or multiple files) using the command line, with a verbose output (see each file name being deleted, instead of a silent screen)

rm -v "/Path/Target folder name"

MacOS - How to remove a folder (or file) without being prompted for yes/no confirmations

rm -r "/Path/Target folder name"