Simple While Loop
Ok I am wanting to figure out a simple script that will implement a while loop to make a simple text file with multiple entries eg.
userlist (file name) user,1,user1@domain.com user,2,user2@domain.com user,3,user3@domain.com etc. now I know this is childs play but people got to start somewhere. Thanks in advance! |
|
You seem to putting the cart before the horse. Before you conclude that you need a while loop, perhaps you should describe what is the nature of the input data, where it comes from, and how you will parse it, if necessary. You are describing a programming conditional statement, without mentioning any of the conditions. A more strictly bounded loop may be more appropriate, or perhaps no looping at all.
This does sound a bit like homework. Please describe your objective and support it with some sample data. --- rod. |
This is what I have come up with
#!/bin/bash x=1 while [ $x -le 5 ] do echo "User,$x,user$x@abcd.com" x=$(( $x + 1 )) done when appended to a file it would create User,1,user1@abcd.com User,2,user2@abcd.com User,3,user3@abcd.com User,4,user4@abcd.com User,5,user5@abcd.com I am using this file as variables to add ldap entries. Not exactly homework but it is class work, and yes im a noob lol. Thanks for the help LQ seems like a great place to be! |
It works and congratulations on that :)
It could be more elegantly done using an arithmetic for loop (not tested): Code:
#!/bin/bash |
All times are GMT -5. The time now is 02:47 AM. |