I have got a directory containing files of type *.cpp
.So i would like to copy each file in the directory and to paste it in the same directory by using
cp -a *.cpp
with an option to remove the .cpp while pasting. Is it possible?
Here is a simple bash script. This script assumes that the file name only contains one "." character and splits based on that.
#!/bin/sh
for f in *.cpp; do
#This line splits the file name on the delimiter "."
baseName=`echo $f | cut -d "." -f 1`
newExtension=".new"
cp $f $baseName$newExtension
done