In your loop, i
is a variable, you need to access the contents of the variable with $
, so it should be cat $i >> X
. Otherwise, it thinks you want to cat
the file named i
, which doesn't exist. $i
gives you the name stored inside the variable i
.
You will run into the same issue with mv
... You will want \mv X $i