Appologies if you also read this on gslug list.

Excerpted from a backup script (bash) I am writing for my personal use.

$selection is the directory name with leading "/", such as "/home". I want to strip the "/" from the name to use in the filename of the backup.

example:  /home is directory to backup & assigned to $selection
        I want Selection to be home (without the /)

I've tried several variations of tr and sed to delete the "/" from the directory name without success.

########
selectd()
{
    PS3='directory? '
    select selection in $DIR_STACK; do
        if [ $selection ]; then
            break
        else
            echo 'ONLY the above entries allowed'
        fi
    done
}

selectd


#...@#@ this is where I'm having problem
Selection=echo  "$selection" | tr -d '/'

# BACKUP is backup device, $Selection becomes part of filename
output="/BACKUP/$Selection.$(date +%d%m%y).bz2"  ## directory > filename

echo "Doing full backup, from $selection,  saving output to $output"

timestamp="$(date +'%m%d%I%M')"

find $selection -depth -type f -user ${USER:-LOGNAME} | \
  pax -w -x cpio | $compress > $output

  ##########

Thanks in advance for any suggestions!
--
Thanks, Tom (retired penguin)
openSuSE 11.3-M4, kde 4.4.0
FF 3.6.0

Reply via email to