Rename the file with specific pattern

Hello

I am making a script where I need to rename the files but with different names.The file name could be change according to the product
I made a logic but that is not working properly

 arr=$(echo a@b@c | tr "@" "\n")
 echo $arr
 output is a b c
 arry=$(echo d@e@f | tr "@" "\n")
 echo $arry
 output is d e f
 for a in $arr;do for l in $arry;do echo $a$l;done;done

But It is not giving me the desiered output.It is giving me the below output

ad
ae
af
bd
be
bf
cd
ce
cf

where as I need the below output

ad
be
cf

Please suggest

Your code is not using or creating any filenames. The subject line of this thread is "Rename the file with specific pattern".

Is this a homework assignment?

What files do you have?

What specific pattern do you want to match?

What new name do you want to give to the file(s) that match the pattern?

What OS and shell are you using?

Hi.

$ paste -d "" <(echo -e "a\nb\nc" ) <( echo -e "d\ne\nf" )
ad
be
cf

If this was for others would probably use printf instead of echo

$ paste -d "" <(printf "a\nb\nc" ) <( printf "d\ne\nf" )
ad
be
cf

This is for system:

OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian 5.0.8 (lenny, workstation) 
bash GNU bash 3.2.39
echo - is a shell builtin [bash]
paste (GNU coreutils) 6.10

Best wishes ... cheers, drl

As drl produced expected output, like this also you may try using sed, BTW whats your ultimate aim ? Do you think your description is clear ?

$ arr="a@b@c"
$ arry="d@e@f"
$ paste -d'\0' <(sed 's/@/\n/g' <<<$arr) <(sed 's/@/\n/g' <<<$arry)
ad
be
cf

My description was not clear.I apologies for this

my intention was to rename the file here a b c are files which will renamed with d e and f files.I was using the above logic in my sciript to rename it.File a should be replaced with d,b file with e and c with f.

---------- Post updated at 02:25 PM ---------- Previous update was at 02:23 PM ----------

I am using Linux and bash shell