I have a directory with these files:app_conf.jboss.app_hostname_20160913_191141.tgz  app_conf.jboss.app_hostname_20160913_194047.tgz  app_conf.provider.app_hostname_20160913_194044.tgz  app_conf.provider.app_hostname_20160928_071002.tgz  app_conf.deployments.ear.app_hostname_20160913_194047.tgz  app_conf.deployments.ear.app_hostname_20160915_071005.tgz  app_conf.bin.jboss_cluster.app_hostname_20160913_194044.tgz  app_conf.bin.jboss_cluster.app_hostname_20160913_194047.tgz  app_conf.bin.conf.app_hostname_20160913_194043.tgz  app_conf.bin.conf.app_hostname_20160913_194047.tgzThe files are varying only by date because could be exists multiple files with the same part of the name (string_name_YYMMDD_HHMMSS.tgz)I need a script that only copy the last version of the file depending your type.Example:string_name1_20160913_194047.tgz.string_name1_20160913_194043.tgz. It shoul copy only string_name1_20160913_194047.tgz.And do this for all the rest type of files...For Now I'm copying manually:scp username@host:/tmp/string_name1_20160913_194047.tgz /home/config/Appreciate any input on this.
Script to copy remote files based on file name and date comparison of their names
shell script;centos;filenames;scp