bash scripting
I am new to Linux and I'm enrolled in college course. I need help writing a simple bash script, but I have not had any instruction on scripting. We are suppose to use the "man" pages and write the scripts on our own. Can anyone provide links that better describe how to script. The man pages are more for Linux users, not for us Windows users. The pages read more like greek to me. I need to write a script to add users from a list. The list is in the format of Lastname,Firstname and I need to username to first initial last name (flastname) all lower case. What command do I use and where can I find simpler instructions on how to do this.
|
http://www.tldp.org/LDP/abs/html/
Google is your friend.. ;) And that is probably one of the best online tutorials covering bash scripting. |
Welcome to LQ. Take a look at the following links to learn bash scripting:
http://www.tldp.org/LDP/abs/html/ http://www-106.ibm.com/developerwork...ry/l-bash.html http://www.linuxcommand.org/writing_shell_scripts.php Regards |
Yep.... still greek to me. I think I'm stuck wiht using Windows for ever. Thanks for the help anyways.
|
Here's somethign I'd like to see. By the time you read this, my assignment will be over with so don't worry about doing my work for me. Can someone that knows what they are doing post a bash script that adds user from a list? The list format will be Firstname, Lastname. The username is going to be the first initial wit the last name, all lowercase. (flastname). I'd just like to see where I was going wrong. Most of the time my script would just hang and do nothing, or it would return invalid username.
|
Quote:
Quote:
If you want help, why not post your script you have and we could perhaps tutor you on your mistakes, instead of giving you the answer.. then you'll actually learn something most likely.. but remember our rules you agreed to and that I linked to above.. don't expect anyone to do the work for you.. :tisk: |
userscript.sh
#!/bin/bash clear read TheUSER while [ "TheUSER" != "" ] do read TheUSER echo The User is $TheUSER useradd $TheUSER done echo "All user names have been added" my list file was cut down to just a sinlge name for testing. userlist.txt contains: Howard Howard1 Fine I removed the first names and added a 1 to the second Howard to test the script before I tried using the cut command to: #!/bin/bash clear read TheUSER while [ "TheUSER" != "" ] do read TheUSER | cut -f2-1 (I think this would return the first chacter after the comma) | tr [A-Z] [a-z] (I think this would change all caharters to lowercase) echo The User is $TheUSER useradd $TheUSER done echo "All user names have been added" The actual userlist.txt will be: Howard,Moe Howard,Curly Fine,Larry |
All times are GMT -5. The time now is 08:09 AM. |