#!/bin/bash dir="$1" if [[ 'X' == "X${dir}" ]] then echo "usage: $0 [home|work]" exit fi cd /${dir} find . -maxdepth 1 -type d | cut --bytes=3-99 | grep -v 'lost+found' | grep -v '^$' | sort -u > /root/bin/${dir}.txt