How can I move multiple files to a directory while changing their names and extensions using bash?

Viewed 1033

There are multiple files in /opt/dir/ABC/ named allfile_123-abc allfile_123-def allfile_123-ghi allfile_123-xxx.

I need the files to be named new_name-abc.pgp new_name-def.pgp new_name-ghi.pgp new_name-xxx.pgp and then moved to /usr/tst/output

for file in /opt/dir/ABC/allfile_123* ; 
do mv $file /usr/tst/output/"$file.pgp"; 
rename allfile_123 new_name /usr/tst/output/*.pgp ; done

I know the above doesn't work because $file = /opt/dir/ABC/allfile_123*. Is it possible to make this work, or is it a different command instead of 'for loop'?

This is for the Autosys application in which the jil contains a command to pass to the command line of a linux server running bash.

I could only find versions of each part of my question but not altogether and I was hoping to keep it on the command line of this jil. Unless a script is absolutely necessary.

1 Answers
Related