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
  • 84,225
  • 14
  • 89
  • 153
M_Zakaria
  • 31
  • 8

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
  • 10,388
  • 3
  • 23
  • 41