Firstly , In the /tmp/test
file path I have the below directories
amb
bmb
cmb
By running the find
command, I am getting the below list of files inside these three directories:
amb/eng/canon.amb
bmb/eng/case.bmb
cmb/eng/hint.cmb
I am trying to take each file from this list1
using a for
loop and based on the file type, *.amb
or *.bmb
or *.cmb
that particulal IF should execute:
cd /tmp/test
find */ -type f -exec ls {} \; > /tmp/test/list1
for file in `cat /tmp/test/list1`
do
if [ -f *.amb ]
then
sed "s/amb/amx/g" /tmp/test/list1 > /tmp/test/list2
ls /tmp/test/list2 >> /tmp/test/finallist
fi
if [ -f *.bmb ]
then
sed "s/bmb/bmx/g" /tmp/test/list1 > /tmp/test/list2
ls /tmp/test/list2 >> /tmp/test/finallist
fi
if [ -f *.cmb ]
then
sed "s/cmb/cmx/g" /tmp/test/list1 > /tmp/test/list2
ls /tmp/test/list2 >> /tmp/test/finallist
fi
done
echo "*********************"
echo -e "\nFinal list of files after replacing from tmp area"
felist=`cat /tmp/test/finallist`
echo -e "\nfefiles_list=`echo $felist`"
So my final output should be:
amx/eng/canon.amx
bmx/eng/case.bmx
cmx/eng/hint.cmx