Current working directory is PATH2
ARG2=3
$ for i in {1..$ARG2}
do
cd FIXBILL_$i
cp output.txt $PATH1
cd $PATH1
mv output.txt output_$i.txt
cd $PATH2
done
sh[3]: FIXBILL_{1..3}: not found.
cp: cannot access output.txt: No such file or directory
mv: output.txt: cannot access: No such file or directory
it should take FIXBILL_1 , FIXBILL_2 & FIXBILL_3 but instead its taking FIXBILL_{1..3}. Please help.
for i in {1..$ARG2}
withfor i in $(seq 1 "$ARG2")
(beware of *, for example). – Apr 08 '21 at 22:37sh
, a simpler shell that does not understand the{1..3}
expansion, so it treats the characters as filename components. Thebash
shell supports{1..3}
. – waltinator Apr 08 '21 at 22:45{1..$var}
– glenn jackman Apr 09 '21 at 02:29