I'm looking for the best way to handle essentially performing a Unix2Dos on all files with a certain extension .nux
.
I actually want to rename the extension to .nun
.
Right now my code manually pushes into each hard coded directory to achieve this but I would think / hope that there's a cleaner way to do this. A code that could recursively dive into every folder below /testpath/temp/
and "rename" the .nux
file(s) to .nun
and change the Linux line endings to Windows line endings.
BASH VERSION 3.2.57(2)-release
pushd /testpath/temp/xyz
if [[ -f PRXYZ.NUX ]]
then
sed 's/$/\r/' PRXYZ.NUX > PRXYZ.NUN
rm PRXYZ.NUX
fi
popd
pushd /testpath/temp/abc
if [[ -f PRABC.NUX ]]
then
sed 's/$/\r/' PRABC.NUX > PRABC.NUN
rm PRABC.NUX
fi
popd
pushd /testpath/temp/lmn
if [[ -f PRLMN.NUX ]]
then
sed 's/$/\r/' PRLMN.NUX > PRLMN.NUN
rm PRLMN.NUX
fi
popd
find
and itsexec
option. Something likefind . -name "*.nux" -exec sed [...]
should do what you want. This command is inclompete, and completing it is left as an exercise to the reader ;)