I'm new to bash scripting. The requirement is similar to BASH copy all files except one. I'm trying to copy all files that starts with file and exclude one file that starts with file~ (backup file). This is what I hvae tried so far with bash.
path1="/home/dir1/file*" ( I know this * doesn't work - wildcards)
file_to_exclude="/home/dir1/file~*"
dest=/var/dest
count=`ls -l "$path1" 2>/dev/null | wc -l`
if [ $count !=0 ]
then
cp -p !$file_to_exclude $path1 $dest (Not sure if this is the way to exclude backup file)
fi
Could anyone please help me how to resolve this?