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!
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all
I know this is a Linux forum but i am taking a course in school and we are using UNIX and we are working in the born again shell. and for a lab we have to make a list of some commands. But I am having some trouble with the grep command. I'm not asking for any one to do this for me just asking for some one to point me in the direction of a tutorial that can help me figure out witch commands to use. Or if some one wants to explain to me what commands to use that would so helpful. I know I need to use []* and <> I am just not sure how to use them in the command.
here is what I need to do.
6.) Now to play with grep. Using the file /etc/passwd, write the following greps (the basic form will be “cat /etc/passwd | grep pattern”
a) lines that have “russ”
b) users that use bash
c) users that do not use bash
d) the count of users that use bash
e) The number of users in the /home directory
f) Dead accounts (users with a false shell) and what line number they are on
Thank you so much to helps me out with this and who every does you would seriously be the coolest stranger in the world!!!
1. I don't understand the reason of the syntax "cat /etc/passwd | grep pattern" since grep accept a file name as argument, but if your course notes do that, stick with it.
2. Do a copy of /etc/passwd and work on that (you never know...)
3. All you need is the grep command and its options, so look at man grep and start to figure it out. Take in mind that the syntax of the grep command is
Code:
grep [options] PATTERN [FILE...]
where PATTERN is the word or the pattern to look for inside FILE.
Hey trickykid, apart the fact he/she could have tried to do the homework by him/herself, don't you think that the usage of the count option of grep would be more correct in this context?
Hey trickykid, apart the fact he/she could have tried to do the homework by him/herself, don't you think that the usage of the count option of grep would be more correct in this context?
True...somthing like...
Code:
root@host# grep -c home /etc/passwd
krdan4th, you will NEVER learn Linux if you don't do your own homework...
Hey trickykid, apart the fact he/she could have tried to do the homework by him/herself, don't you think that the usage of the count option of grep would be more correct in this context?
True, but then again, I went way beyond than I should have.
I did stick to the cat /etc/passwd bit they are stuck to using apparently, IMHO I would have just appended the filename at the end, etc.
Thanks a lot Trickykid! That was so much help!! when I was reading the question I was looking at it and was wonder what the hell was I supposed to do. but now that you showed me what to do i now understand what I was supposed to do and feel like a major moron now. Seeing that, that was so easy.
I am a huge noob to the whole Unix and Linux thing and not so great with using the console since windows was all point and click.
I hope to one day get completely away from windows and use just Linux ia m trying out Ubuntu at the moment and like it so far.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.