Shell Script to Rename & Move files in Unix

      

Problem Statement: I have few files in source directory. I have to move them to another destination directory. The source directory have *.txt files that needs to be moved to destination directory. The destination filename should be *.txt.backup.

So how to accomplish the above task in Unix Shell Script?

Well the solution is simple:

cd source/
for file in *.txt
do
   mv "${file}" ../destination/"${file}.backup"

Run a loop for each txt file in source/ directory and call mv command with parameters.

Does the above problem have a simpler solution than this?


Facebook  Twitter      Stumbleupon  Delicious
  

One Comment on “Shell Script to Rename & Move files in Unix”

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

Copyright © 2010 ViralPatel.net. All rights reserved.