0

first i want to read number of files that he want to create it

#!/bin/bash

touch file{0..$number}

I trayed with this syntax but output is the following

    file{0..number}      >> as example
Cyrus
  • 77,979
  • 13
  • 71
  • 125
M_Zakaria
  • 31
  • 7

1 Answers1

2

In bash variable expansion happens after sequence expression expansion, so you can't use variables inside a sequence expression.

Instead you need to use something like a for loop:

number=3
for ((i=0; i<=number; i++))
do
  touch file${i}
done
match
  • 8,748
  • 2
  • 21
  • 38