Quick File Copy on File Name with Sample Extension

By default, some of the application installation provide you a sample configuration file. Usually the sample of configuration will end with name like *.sample, *.default and so on. Let say you have 20 of *.sample files and it will take you some time to copy, move or rename one by one. Lets do some quicker way which will save more time.

Create a sample file file random name ended with *.sample. Example

touch apple.sample.cfg
touch microsoft.sample.cfg
touch php.sample.cfg
touch config.sample.cfg
touch apache.sample.cfg
touch mysql.sample.cfg
touch pgsql.sample.cfg
touch cacti.sample.cfg
touch wordpress.sample.cfg
touch jessicaalba.sample.cfg

Now you have all the sample configuration, you are going to use them. Are you going to copy one by another and change the same with .cfg prefix? We can do it, in a better and faster way.

Make a new directory to store all the sample file

mkdir sample
cp *.sample.cfg sample/

After that, go to sample directory and copy the files to a location

cd sample 
for d  in `ls *.sample.cfg`; do cp $d `echo $d | sed s/sample.cfg/cfg`; done

That one simple line will easily save you 1-2 minutes.