Team,
Presently i have some 20 files which i need to copy and store in the common directory.

below is the example:
script name: dir.sh
cp /tmp/abc /home/abc/xyz
cp /tmp/def /home/abc/xyz
cp /tmp/hij /home/abc/xyz

The above script is run, it copies the source files on the destination directory(xyz), wanted to make it more interesting.
a)it should prompt me if the directory exist/else create it
b)cp command should be taken as input file, so that incase i have more changes i can directly make changes to the file where all copy commands are stored
c)maintain the copy files on the basis of the date when it was copied,so that it could enable me delete only those files which are older by 3 days old.

Have prepared for the file creation(a), need assistance on the others(i.e b & c)

read sd
if [ ! -d "/home/abc/$sd" ] && mkdir "/home/abc/$sd"; then
 echo "That directory does not exists,new directory was created"
 else
      echo "Directory present"
fi

Regards
Whizkid

cpfile=$HOME/bin/cpfile
dest=/home/abc
for file in /tmp/*
do
  printf 'cp "%s" "%s"\n'  "$file" "$dest"
done > "$cpfile"

Use find to list files older than 3 days:

find "$dest" -type f -mtime +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.