[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 656
  • Last Modified:

file rename using bash shell

I'm in need of a bash shell script to
remove the extension *.bak from all files that contain the extension *.bak.
the file names are unknown.
the following commands strip the extension from the filename:
 filename=/test/file.bak
 outfile=${filename%.bak}
 cp filename outfile
will change one file, I need a way of changing multiple files that have unknow filenames. Probably need to use ls somehow.  does anyone know the shell commands to do this?
0
desk
Asked:
desk
1 Solution
 
ozoCommented:
for filename in /test/*.bak ; do
  cp $filename ${filename%.bak}
done
0
 
deskAuthor Commented:
Thank You
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now