I have a set of files in a folder, I need a script which basically checks whether each file is present or not and if any one of them is missing , the script should fail (exit out) displaying the name of the file which does not exist .
this is the list of files
insert_dma_prspct_daily_tmp.sql
t_prspct_cntct_daily_tmp_dedup_CARI.sql
t_prspct_cntct_daily_tmp_dedup_CARI.sql
t_prspct_cntct_daily_tmp_copy_prspct_id.sql
t_prspct_cntct_daily_tmp_delete_reload.sql
t_raprspct_hdr_daily_tmp_insert.sql
t_ra_prspct_match_ref_truncate.sql
check_reactive_cnt.sql
t_prspct_cntct_daily_tmp_update.sql
t_prspct_cntct_daily_dup_PID_update.sql
t_prspct_cntct_daily_tmp_dedup.sql
delete_dup_prspct_daily_tmp.sql
t_reactive_prspct_insert.sql
t_prspct_cntct_non_accept_delete.sql
process_old_response.sql
t_current_prspct_response_update.sql
t_prspct_cntct_hist_log_insert.sql
t_prspct_cntct_hist_update.sql
t_choice_volunteer_insert.sql
t_choice_bus_volunteer_insert.sql
t_volunteer_update.sql
t_bus_volunteer_update.sql
t_bus_volunteer_hist_mtl_insert.sql
t_bus_volunteer_mtl_delete.sql
t_choice_bus_volunteer_mtl_insert.sql
t_bus_volunteer_update.sql
t_prspct_sales_agent_update.sql
Assuming list of files is in a file called "file_list".
cat file_list|while read F
do
if [ -f $F ]
then
echo "Missing: $F"
fi
done
This finds all the missing files. If you want to stop after the first error, put an "exit" or a "break" after the "echo".
but if its missing it should come out of the loop ...the loop should not move ahead
if you have PHP
<?php
$list_of_files = "file";
$handle = fopen($list_of_files,"r");
while (!feof($handle)) {
$file = trim(fgets($handle,4096 ));
if ( !file_exists($file) ){
echo "File: $file does not exists\n";
break;
}
}
fclose($handle);
?>