#!/bin/sh # move files into target directory. # the directory is created if it does not exist. # arguments: target file ... target="$1" shift mkdir -p "$target" && for a in "$@" do b="$target/$(basename "$a")" if test -e "$b" then echo "file already exists '$b'" else mv "$a" "$b" fi done