Category Archives: linux

bash string manipulation

These quick string manipulations might save you some time. This works with bash starting from version 4.0 Function Input String s Bash Output String Show ABC123abc123 ${s} ABC123abc123 Show UPPERCASE ABC123abc123 ${s^^} ABC123ABC123 Show lowercase ABC123abc123 ${s,,} abc123abc123 Show length … Continue reading

Posted in bash, linux, macosx | Tagged , , , , | Leave a comment

Mass SMTP mailer from shell

I configured my local mail system to use the gmail SMTP server. Install package ssmtp and configure /etc/ssmtp/ssmtp.conf with following parameters: root=postmaster AuthUser=kdguntu@gmail.com AuthPass=NoWAYiWILLtellYOUmypassWORD FromLineOverride=YES mailhub=smtp.gmail.com:587 UseSTARTTLS=YES hostname=defaults.be This scripts reads an input file (listusers.txt) with ; seperated values for … Continue reading

Posted in bash, linux, mail, server | Tagged , , | Leave a comment

Generate easy passwords

This script generates combinations of words to form a password. These passwords are easier to remember than true random garbage combinations, which can’t be remembered by anyone. Moreover the passwords are not dictionary words and too difficult to be guessed … Continue reading

Posted in bash, linux, macosx, regex, ubuntu | Tagged , , , , , | Leave a comment

Watermark all images

Recently I had to watermark around 500 images for an existing site. Images are replaced with watermarked images! I had problems with temporary/hidden images in the directory so the find statement contains a ! -name “.*” which negates hidden files … Continue reading

Posted in bash, find, linux, macosx, ubuntu | Tagged , , | Leave a comment

Get filename and or extension

This script uses the filename and the extension of a file using shell scripts. This is useful when you have to rename a file or its extension. filenameextension.shraw download  #!/bin/sh # Name: filenameextension.sh # Author: kdguntu@gmail.com # Function: Show filename … Continue reading

Posted in bash, cut, linux, macosx, ubuntu | Tagged , , , , , | Leave a comment

Check if running chrooted

This script checks if we are running in a chroot environment checkchroot.shraw download#!/bin/sh # Name: checkroot.sh # Author: kdguntu@gmail.com # Function: check if the script is running within a chroot environment # Parameter: none # Copyright: 2011 kdguntu@gmail.com GNU GPL … Continue reading

Posted in bash, chroot, linux, stat, ubuntu | Leave a comment

Use a shell function, check if a file exists, true or false

This script uses a shell function to check if a file exists (-f). It returns 0 (zero) if the file exists and 1 if it does not exist. You can write your own check functions for checking if a directory … Continue reading

Posted in bash, cut, function, linux, regex, sed, Uncategorized, windows | Tagged , , | Leave a comment