Build precise queries to find exactly what you need
Press ESC to close
@BARRESOFT
Favorites0
Views0
Projects2
If you want to do it recursive, use find to locate the indicated directory most recent file (on the tree). Then, take the file, and break the loop, indicate that the next file (the most recent unique file) is the find result file. Here is an example code, of modificated lines, excluding *.ini, *.tm? and *.db files: # Loop through each provided directory. for dir in $dirs do check_file= let "DIR_COUNT += 1" > /dev/null # Check if dir exists. full_path=${base_dir}${dir} #Agregado por Cristian Barreto full_path_archivo=`find $full_path -not -name "*.tm?" -not -name "*.ini" -not -name "*.db" $ indiceBarra=`expr match "$full_path_archivo" ".*/"` full_path=`echo $full_path_archivo | cut -c 1-$indiceBarra` #FIN del agregado if [ -d "$full_path" ]; then file_list=$full_path_archivo # Cycle through files, looking for a checkable file. for next_file in "$file_list" do next_filepath=$full_path_archivo if [ "$check_dirs" ]; then # Check if it's a file or directory. if [ -f "$next_filepath" ] || [ -d "$next_filepath" ]; then check_file=1 fi . . . . break #at the end of loop done -------------------------------- done!, remember that $next_filepath must have "$next_filepath" and "${next_filepath}" to support file names with blank spaces like Windows file names. Sorry for my bad english.
Reviewed 13 years ago