Quote:
Originally Posted by astroumut
conversion.sh
Code:
set listcube = dummyfile1.dat
@ i = 0
while ($i <= 3)
@ j = 0
while ($j <= 3)
echo "Finished ${listcube}_${i}_${j}.dat"
@ j ++
end
@ i ++
end
|
Ignoring the "@"s pending your answer to chrism01's question ...
Code:
set listcube = dummyfile1.dat
That sets $1 to listcube, $2 to = and $3 to dummyfile1.dat. I guess you wanted to set $listcube to dummyfile1.dat in which case you can use
Code:
listcube=dummyfile1.dat
It is important that there are no spaces either side of the "=".
has the effect of running
$i <= 3 in a subshell and testing the exit status from the subshell which is always going to be 1 (error, false). In the subshell, bash first processes the redirection operator < and finds it is being asked to redirect input from a file called =. Probably there is no such file and this will result in an error. I guess you want to loop while $i is less than or equal to 3. This will do it
Code:
while [[ "$i" -le 3 ]]
do
<commands>
done
The double quotes around $i are defensive, in case it is empty, unset or contains only whitespace. The "-le" is an arithmetic comparison operator ("<=" is a string comparison operator). The "do" and "done" define the loop body and are essential after while to complete the "compound command".
It seems you are trying to write shellscript by guesswork rather than studying how to do it and that aint never going to work; shellscript is not intuitive. Better you netsearch for bash shellscript introductions (there are lots out there) and study some examples. The Advanced Bash Scripting guide has lots of examples.