Can I Have Some Help Writing This Bash Script Since Is My First Time Doing One?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
no sorry, we can't help you from no starting point at all, that's called cheating. how far have you got of your own accord? ask us some specific question and we can give some specific advice, but we can't just write a script for you.
First, you need to have an interpreter specified by your script. This is what the first line of the script does. That line begins with a #! to signify that it is to execute what follows as the interpreter. I suggest you use /bin/sh, but you can use whatever shell you like.
After that, you need to figure out what commands get usernames from /home and what commands get last login information. You will also need to determine what commands will help break up a many line output into subsets.
Variables can be assigned by
VARIABLE="Text with spaces"
You will need a for loop
for VARIABLE in `command output` ; do
Actually, I'd recommend using
for the 1st line. /bin/sh MAY be symlinked to /bin/bash, but it's not required, and in which case it'll actually be the POSIX sh shell ... which is not the same thing ...
Well hello everyone, i think we started off on the wrong foot here, so let me start again...
I am not asking for anyone to solve this for me , i only need a guide on how to start. i have some small knowledge of linux but not on bash as much. so far i know that i have to use maybe ls -l/home/, i also know that i have to create a file and put all the users in there, i will start the script with
H_TeXMeX_H, can you prove that 'it's best to use '#!/bin/sh' because whatever it is linked to must be Bourne-shell compatible.' ?
AFAIK, it's like I said, it MAY link to bash (or soemthing else) or it's the POSIX sh, but there's no rule saying which or whether what it points to has to be compatible with anything else.
If you can show me link proving otherwise I'd be glad of the update. (seriously)
chrism01, I think the point he is making (which is the same reason I said /bin/sh) is because you will always have /bin/sh on your system. You can't guarantee you will have bash.
What you must understand is that '/bin/sh' will not exist as a real file, it will always be a symlink on modern systems. It will be a symlink to a Bourne compatible shell such as bash or ksh. You can use '/bin/bash' without any problems on most systems. Also, sh and bash are never installed simultaneously on one system, just bash is installed. If sh is installed, the system is ancient and the script will fail in most cases anyway.
To try to summarize it:
The greater concern here is not that sh will exist as the original Bourne shell, it will not. The greater concern is whether bash will exist or will it have been replaced by ksh or some other shell.
I have no real links to veriy whether my way is better, but I think it's better. You can do whichever you think is better. I always use '/bin/sh' because I know this is never the old sh Bourne shell, it's always bash or ksh.