BladeSystem Forums have moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Showing results for 
Search instead for 
Do you mean 

about loop

Regular Advisor

about loop

hi all

Iam new in script
I create a simple script to list all files and directory in current dir
*********
for i in *
if [ -d $i ]
then
echo $i "Directory"
fi
------> I wnant to go next i and esc the next
(what command i put here to do that?)
echo $i
done
********************
thankx

kamal
6 REPLIES
Honored Contributor

Re: about loop

Hi,

Do I understand you correct ?

Something like:

for i in *
do
if [ -d $i ]
then
echo $i "Directory"
else
echo $i "File"
fi
done
Regular Advisor

Re: about loop

thank u for your response
that is true in this example
but
in other case
if i want to esc the next lines and continue
next i

is there any way to do that ?

thankx
Honored Contributor

Re: about loop

Hi,
Could you please describe more in detail.
Which "lines" do you want to esc (skip ?) ?
Highlighted
Honored Contributor

Re: about loop

Hi,

perhaps this is what you are looking for:

for i in *
if [ -d $i ]
then
echo $i "Directory"
fi
continue
echo $i
done

the code is not very useful but you might learn somthing by that.

Regards
Regular Advisor

Re: about loop

I mean

if any one familer with visual basic
*********************************************
for x = 1 to 10
if (any condition) then
(do any thing)
next x ---> (this command return to x again without complete the next lines ).
end if

(any thing)
next
********************************************


i want to know what is this command in unix ?
Honored Contributor

Re: about loop

Hi,

I can give you two examples that will do the same job as the example in basic. Example two is a "direct" translation but the syntax in example 1 should be prefered.


for i in 1 2 3 4 5 6 7 8 9 10
do
if [ (any condition) ]
then
(do something)
else
(do something else)
fi
done

for i in 1 2 3 4 5 6 7 8 9 10
do
if [ (any condition) ]
then
(do something)
continue
fi
(do something else)
done


for x = 1 to 10
if (any condition) then
(do any thing)
next x ---> (this command return to x again without complete the next lines ).
end if

(any thing)
next