LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 10-26-2003, 04:17 PM   #1
ner
Member
 
Registered: Oct 2003
Posts: 40

Rep: Reputation: 15
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
 
Old 10-27-2003, 04:05 AM   #2
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
please post your script, I'd like to see it myself.

have you tried using "sort | uniq" already?
 
Old 10-27-2003, 09:54 AM   #3
ner
Member
 
Registered: Oct 2003
Posts: 40

Original Poster
Rep: Reputation: 15
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..
 
Old 10-27-2003, 12:31 PM   #4
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
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
 
Old 10-27-2003, 03:39 PM   #5
ner
Member
 
Registered: Oct 2003
Posts: 40

Original Poster
Rep: Reputation: 15
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
 
Old 10-27-2003, 04:35 PM   #6
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
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 04:37 PM.
 
Old 10-28-2003, 01:22 AM   #7
KDE4me
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: Reputation: 15
If you want a command I suggest ckpasswd/chkgroup otherwise as said preiously cut paste etc. or awk.
 
Old 10-28-2003, 11:55 AM   #8
ner
Member
 
Registered: Oct 2003
Posts: 40

Original Poster
Rep: Reputation: 15
thanks KDE4me, I will try that too
 
Old 10-28-2003, 12:13 PM   #9
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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.
 
Old 10-28-2003, 01:41 PM   #10
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
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 01:45 PM.
 
Old 10-28-2003, 01:52 PM   #11
ner
Member
 
Registered: Oct 2003
Posts: 40

Original Poster
Rep: Reputation: 15
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 )
 
Old 10-28-2003, 01:55 PM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,394
Blog Entries: 55

Rep: Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565
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 02:07 PM.
 
Old 10-28-2003, 02:12 PM   #13
ner
Member
 
Registered: Oct 2003
Posts: 40

Original Poster
Rep: Reputation: 15
Whith all due respect, how do I address it?
 
Old 10-28-2003, 02:36 PM   #14
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,394
Blog Entries: 55

Rep: Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565Reputation: 3565
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...
 
Old 10-28-2003, 02:41 PM   #15
ner
Member
 
Registered: Oct 2003
Posts: 40

Original Poster
Rep: Reputation: 15
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions markjuggles Programming 2 05-05-2005 12:39 PM
Perl and Regular Expressions Fonk Programming 1 06-27-2004 12:32 PM
Regular Expressions overbored Linux - Software 3 06-24-2004 03:34 PM
Regular expressions aromes Linux - General 1 10-15-2003 01:29 PM
regular expressions? alaios Linux - General 2 06-11-2003 04:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration