Link to home
Start Free TrialLog in
Avatar of steviedeehook
steviedeehookFlag for South Africa

asked on

Bash expansion

Hi,
is there an easier way to mkdir {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}0
THanks
Steven
Avatar of sunnycoder
sunnycoder
Flag of India image

Hi steviedeehook,

i=0
while [ $i -lt 16 ]
do
       mkdir $i
       i=` expr $i + 1`
done

Cheers!
sunnycoder
Avatar of steviedeehook

ASKER

Could you explain that to me a lil?
you set var i to = 0, then each time you create a dir you increase i by 1
what's lt?
what's expr?
What I actually need would be:
i=0; while [ $i -lt 160 ]; do mkdir $i; i=` expr $i + 10`; done; rm -r 0
:-) it's not much shorter, but it'll help when there are more than 15 to create.
Thanks
Steven
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did you need any further clarifications?

please take time to read the grading guidelines here
https://www.experts-exchange.com/help.jsp#hi73
no, sorry, I guess I should have graded u as A,
Just that the answer you gave wasn't totally corrrect, It didn't do what I was looking for and I had to edit it.
But it was the fastest and best service I've had here.
sorry, and thanks
Steven
>Just that the answer you gave wasn't totally corrrect, It didn't do what I was looking for and I had to edit it.
In that case you should post back seeking clarifications unless the edit was too trivial.

I thought the script I gave did actually do what you asked for in the original question ... Out of curiosity what was missing?

Moderators can update the grades. Would you be agreeable to updating the grade to A if I were to post a request in CS?
Yea you can upgrade it to an A.
i=0
while [ $i -lt 160 ]
do mkdir $i
i=` expr $i + 10`
done
rm -r 0
does what I was lookin for
I think you didn't see the 0 at the end of my first command "mkdir {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}0"
Steven.
thanks :) .. You are right ... I missed the 0