#!/bin/sh use this shell
path() { define function 'path'
case "$1" in
*/*) if 1st param supplied to function contains '/'
echo "$1"output the value of $1 to stdout
;;
*) otherwise, prepend the value of $HOME and output the new value to stdout
echo "$HOME/$1"
;;
esac
}
echo -n 'Source: ' Output 'Source:' to stdout (suppress carriage return)
read src read a line from stdin and assign this value to the variable 'src'
src=`path $src` pass the value of 'src' to the 'path' function and overwrite the value of 'src' with the output from 'path'
if [ ! -e "$src" ]; then test if the value of 'src' exists as a file
echo $src does not exist >&2 if no file exists, send a message to stderr
exit 1 quit the script, set $? = 0
fi
echo -n 'Destination: ' Output 'Destination:' to stdout (suppress carriage return)
read dst read a line from stdin and assign this value to the variable 'dst'
dst=`path $dst`pass the value of 'dst' to the 'path' function and overwrite the value of 'dst' with the output from 'path'
mv $src $dst move the file to the dst location