Please do help me out with this. I have to write the following script.
There is a directory named "storage_directory" and it has hundreds of files in it. My script has to move each file from the storage_directory to "temp_directory" After moving each file, it has to create a log of the File name, that is moved into a text file.
Once I run the script, it should be able to move the first file from the "storage_directory" to the "temp_directory" and then create a text file with the name of the files transfered. Then, it has to move the next file in the "storage_directory" to the "temp_directory" and so on... It has to loop through the directory and move the files to "temp_directory"..
mv is destructive, it will delete the original copy after the move, are you sure you don't want to cp first? then rm after you verify the integrity of the file?
#!/bin/ksh
for file in `ls storage_directory`
do
mv storage_directory/$file temp_directory/$file
echo "$file has been moved to temp_directory" >> somelogfile.txt
done