Copy files with deleting suffix in name

cprename

How can be done coping files that have some suffix at the end, into same dir with the smallest command possible:

Example have directory containing files:

  • cassandra.yml.example
  • database.yml.example
  • facebook.yml.example
  • cache.yml.example
  • system.yml.example

need to copy them and have names like this:

  • cassandra.yml
  • database.yml
  • facebook.yml
  • cache.yml
  • system.yml

Best Answer

for x in /path/to/*.example
do
  cp "$x" "${x%%.example}"
done

Will make a copy without the .example into the same folder as the source file.

Related Question