I want create per each line of text file create nested directory.
for (( i=0;i<=$(cat filename | wc -l);i++ ))
do
mkdir /PATH/$i
done
I want create per each line of text file create nested directory.
for (( i=0;i<=$(cat filename | wc -l);i++ ))
do
mkdir /PATH/$i
done
You are missing the third part of for (( init; condition; increment))
. The correct version should be
for (( i=0; i<=$(cat filename | wc -l); i++ )); do
mkdir /PATH/$i
done
However, this is a very crude way to tackle the problem. A better approach would be the following (courtesy of tripleee)
seq 0 $(wc -l <filename) | xargs -I mkdir /PATH/{}
Note that both commands will create one directory more than the file has lines. For a file with two lines the directories 0
, 1
, and 2
will be created. If this was an bug in your original script, change the 0
in the scripts to 1
.