vendredi 1 septembre 2017

Shell - Increment number in for loop

I want to prepare a shell script using if and for loop.

The concept of this script is, I have few folders(name+number) like below.

f0

f1

f2

f3

f4

Script looks like,

count=0

So the script will move the first folder to another folder (folder name is f so, f + count= f0 ),

mv f0 /tmp

If it is a success then it'll print success. Else it'll move 2'nd folder like f+count+1=> f+0+1 ==>f1

mv f1 /tmp

If this step get success then print success, else again increase the count=count+1 f+count+1 => f+1+1 =>f3

mv f2 /tmp

Aucun commentaire:

Enregistrer un commentaire