#!/bin/bash -e [[ $# == 1 ]] || { echo "Usage: $0 username"; exit; } USERNAME=$1 HOMEDIR=$(eval echo ~$USERNAME) userdel $USERNAME && \ { [[ -d $HOMEDIR ]] && \ echo "Directory $HOMEDIR wasn't removed. You can remove it manually."; }