Remove all files and folders including hidden files on bash

To remove all files and folders including hidden files such .gitignore, .htaccess, .git etc. on bash you can use the following command:

Is the same as:

But ever shorter. ūüėČ

Wipe a disk via Linux shell

This is how to wipe a disk via Linux shell:

The command above erases all data on the device /dev/sdc and overrides the data 2¬†times. Finally every bit is overridden by zeros. So in sum it takes 3 iterations to wipe a disk via Linux shell. n specifies the number of iterations taken place […]

wordpress cron: using wp_mail function

Today I had to solve the problem, that my wordpress cron throws an exception like this when sending an email via wp_mail function inside a cron scheduled event function.

The wordpress cron was registered like that:

And the wordpress cron mechanism was triggered via Linux crontab:

Problem with wp_mail in wordpress cron […]

Delete x files from folder in a for i loop

Recently I tried to remove a big bunch of files from one of my raspberry pies where ffmpeg had swamped my SD-card with too many capture images. So I had to delete x files from folder. I just tried:

But that gave me an “unable to execute /bin/rm: Argument list too long” error message. […]

Count search results on Linux shell

Lets imagine you want to search for a term in a file and you want to know, how often it can be found in the file. With this command combination you can count search results on bash:

This is how this way to count search results works: The input file is opened in¬†less. Afterwards […]

Formatted CSV output on Linux shell

If you want to output a CSV file on Linux shell, you could just open it with less, cat or nano (un-formatted CSV output):

The problem with this approach is, that you will get an unformatted ugly chunk of characters¬†like that: A much better way is it, to use the less command in combination with […]

Associative arrays (hash, dictionary) on bash

This is how to create associative arrays (hash, dictionary) on bash:

This script was made to¬†purge the varnish on one of my clusters. But the important stuff is the declaration of the associative array with¬† DOMAINS['LIVE']="www.ask-sheldon.com";¬†and how to access the values of the array (with¬† REQUEST_DOMAIN=${DOMAINS["$1"]};). “$1” is the array key to select the value. By the […]