Shell script question

daily few files will be available in one directories /azure/file and it should be moved to other directories /azure/file/recent directories if I run my script.

azure/files> ll *7847*
N7847.TXTFILE
N7847.DMNFILE

Once the script is triggered the above file should be moved to the /azure/file/recent if the files are not present it should not trigger error.

azure/files/recent >

i am not getting the right command to execute the above task.

One approach would be to change to the azzure directory, check if each entry matching a glob is a file and if it is move it into the recent directory

cd azzure/files
for file in ./* ; do
   if [ -f $file ] ; then
      mv $file recent
   fi
done
1 Like

Close, but if I understand what ramkumar15 is trying to do, I think the line:

for file in ./* ; do

needs to be changed to:

for file in *7847* ; do
1 Like

hi don,

thanks for your answers. I have tried it and it works now.