Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
|
10-26-2003, 03:17 PM
|
#1
|
Member
Registered: Oct 2003
Posts: 40
Rep:
|
help with REGULAR EXPRESSIONS
I need commands for finding duplicate uid's and logins in the /etc/passwd file. I have a suggestion to use cut, sort and uniq, but I have no clue how to put all this together.
thnx in advance

|
|
|
10-27-2003, 03:05 AM
|
#2
|
Member
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613
Rep:
|
please post your script, I'd like to see it myself.
have you tried using "sort | uniq" already?
|
|
|
10-27-2003, 08:54 AM
|
#3
|
Member
Registered: Oct 2003
Posts: 40
Original Poster
Rep:
|
thank you for your reply, I will try playing with piping
no, didn't try anything yet, because I did not know where to start. I know that uniq can replace duplicate entries or something like that, but I do not need it replaced, just found.. We just started regular expressions, globing and all that, and we got stuck on this question..
|
|
|
10-27-2003, 11:31 AM
|
#4
|
Member
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613
Rep:
|
I have a kind of fealing this is some homework excersise
try to read the manual pages; "man cut" is a good start, and you'll quickly discover how to fetch the first field of the /etc/passwd file
btw I don't know how this question is related to regular expressions 
|
|
|
10-27-2003, 02:39 PM
|
#5
|
Member
Registered: Oct 2003
Posts: 40
Original Poster
Rep:
|
I don't know how it relates to regular expressions eiter, but it came in the regular expressions lab.. We were able to solve all the rest of the problems but this one..
thanks for your help, I will try it after I come back from college tonight, because I have until tomorrow to turn it in 
|
|
|
10-27-2003, 03:35 PM
|
#6
|
Member
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613
Rep:
|
hehe  good luck with your excersise.
regular expressions can be used for pattern matching. (some advanced text search) guess you don't need it here, since you just want the first field.
just one little advice: Just start with small commands, and see what results you get, then add more and more options to see how the data steam changes (until you have the desired effect), and add another command in the pipe.
Last edited by yapp; 10-27-2003 at 03:37 PM.
|
|
|
10-28-2003, 12:22 AM
|
#7
|
Member
Registered: Apr 2003
Location: Australia
Distribution: RedHat 9.0 / Slackware 9.0/ FreeBSD 4.8 / Solaris 8 x86 / Mandrake 9.0
Posts: 90
Rep:
|
If you want a command I suggest ckpasswd/chkgroup otherwise as said preiously cut paste etc. or awk.
|
|
|
10-28-2003, 10:55 AM
|
#8
|
Member
Registered: Oct 2003
Posts: 40
Original Poster
Rep:
|
thanks KDE4me, I will try that too 
|
|
|
10-28-2003, 11:13 AM
|
#9
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
i can do it but not without writing to a file, if anyone can do it just with pipes all in one statement i'd like to know how.
|
|
|
10-28-2003, 12:41 PM
|
#10
|
Member
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613
Rep:
|
all right... (though I still have the fealing I'm doing someones homework)
And indeed, all you need it cut. sort, and uniq.
Code:
cut -f 1 -d ':' < /etc/passwd | sort | uniq -d
and if you'd like to win the "unless use of cat award"
Code:
cat /etc/passwd | cut -f 1 -d ':' | sort | uniq -d
(but I think this is a bit easier to understand)
Last edited by yapp; 10-28-2003 at 12:45 PM.
|
|
|
10-28-2003, 12:52 PM
|
#11
|
Member
Registered: Oct 2003
Posts: 40
Original Poster
Rep:
|
thank you yapp!!  works great! Hving this line, I can figure out how to do the same for UIDs (or at least I hope so  )
|
|
|
10-28-2003, 12:55 PM
|
#12
|
Moderator
Registered: May 2001
Posts: 29,415
|
We were able to solve all the rest of the problems but this one (...) because I have until tomorrow to turn it in
Ner, I am under the impression we're helping you to complete your assignments. LQ has rules against asking for ready made answers where homework is concerned. This doesn't necessarily mean we're against helping you with your homework, but assignments are made to test your skills, ingenuity and knowledge. If you can show what you're sposed to do by posting idea's or scripts, then it's all OK. Asking for ready made answers on LQ for assignments is no substitute for learning.
Please address this issue now before adding new or replying to threads.
Last edited by unSpawn; 10-28-2003 at 01:07 PM.
|
|
|
10-28-2003, 01:12 PM
|
#13
|
Member
Registered: Oct 2003
Posts: 40
Original Poster
Rep:
|
Whith all due respect, how do I address it?
|
|
|
10-28-2003, 01:36 PM
|
#14
|
Moderator
Registered: May 2001
Posts: 29,415
|
Whith all due respect, how do I address it?
- by understanding the LQ rules on homework, and
- by acknowledging you next time should post examples of what you tried and where you failed.
As moderator all I have to add is you should understand the difference: LQ members will help you by thinking with you about solving your problem, we just don't want to do your homework for you, that's all...
|
|
|
10-28-2003, 01:41 PM
|
#15
|
Member
Registered: Oct 2003
Posts: 40
Original Poster
Rep:
|
great, I do not want LQ members to do my homework for me either, all I need are examples and ideas.
By the way, even though I am not sure yet why we need < in the cut -f 1 -d ':' <..., I figured out how to do uids- put 3 instead of one, because the uid is the third field
Thanks again yapp
|
|
|
All times are GMT -5. The time now is 06:55 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|