For example:I have 100 folder names saved in a text file, how can I apply different command line in the same for loop for every 10 names?In other words If I want to rename every 10 folders with a different name how can I apply the mv command in the same for loop for every 10 items in the text file?#!/bin/bash -fsource=PATH TO THE DATA (100 FOLDERS)for f in $(cat text.txt); do mv ${source}/old folder name ${source}/ new folder namedone
Run for loop with sections of different behavior
bash
since you have them in a text file, you could run two for loops with different index integers and address the files via their positions in the text file:for (( i=0 ; i<=9 ; i++ )) ; do  newpos=$i_files  for (( j=1 ; j<=10 ; j++ )) ; do     mv $( sed -n $(( $i*10+$j ))p filelist) $newpos  donedonesince it is about mv you can even use blocks of your input file with sed for (( i=0 ; i<=9 ; i++ )) ; do    newpos=$i_files    mv $( sed -n $(( $i*10+1 )),$(( ($i+1)*10 ))p filelist) $newpos doneExplanation on the sed part: sed -n 4,8p file will print lines 4 through 8 of file.