my program is designed to take the first parameters as extension, then the rest of the parameters as files to be searched for and, if found, modified by the extension. If not found, it prints an error.
Everything is great until: ./chExt.sh 'com' 'king cobra.dat'
where $file splits up the two words into 'king' and 'cobra.dat' then runs them separately. I need it to read as a whole 'king cobra.dat' into $file.
I heard something about using "shift" to get it to read as a whole, but I'm not sure how to implement it.
#!/bin/csh \
set ext="$1"
shift
echo the remaining are $*
foreach file ($*)
echo $file
if (-r "$file") then
set newName=`echo "$file" | sed 's/\.[A-Za-z0-9]*$/'".$ext"'/g'`
echo $newName
if ( "$file" == "$newName" ) then
:
else
mv "$file" "$newName"
endif
end
else
echo "$file": No such file
end
endif
Thanks!