user2366427
user2366427

Reputation: 17

BASH ,"touch" and "ln-s" inside for loop

while running this code , I get this error:

syntax error near unexpected token (' touch FILE$i FILE($i+1);'

what is wrong ?

#!/bin/bash

  for ((i=1; i<=99; i++ ));
    do        
    touch FILE$i FILE($i+1);
    ln -s FILE$i FILE($i+1);
       
     done


Upvotes: 0

Views: 148

Answers (1)

glenn jackman
glenn jackman

Reputation: 246764

To do arithmetic, use the $((...)) syntax:

    touch FILE$i FILE$(($i+1))

See https://www.gnu.org/software/bash/manual/bash.html#Arithmetic-Expansion

Upvotes: 1

Related Questions