How to parse /etc/passwd by means of grep?
hi guys
plz plz help me in this query in Redhat Linux in the /etc/passwd file i need to find the rows where column 5 is empty using only grep there is a pattern in all lines where column 5 is empty: the first column in all of them is either letters or numbers, the second is always x, the third is numebrs and the fourth is numbers plz help me guys and ASAP thanks a lot |
Hello and welcome to LinuxQuestions,
First of all, please spell out your words, text speak is not appreciated on LQ forums. Besides that this sound a lot like homework and although it's not against the LQ Rules to ask for help with homework, you shouldn't post it verbatim nor should you expect us to do the work for you. We'll be glad to point you in the right direction if you show us what you've already figured out and where it's failing. And as a last point, don't ask for privileged attention, it's only urgent to you, not to us who are all volunteers here. A good starting point is Google and the man page for grep Code:
man grep Kind regards, Eric |
:twocents:
Code:
Hope this is not homework.............. :rolleyes: |
Your problem is only urgent to you, not to the volunteers who give their time freely to answer questions.
Why can you only use grep? That sounds like a homework question. Bash and awk are more naturally suited to the task. |
Please use a descriptive title for your thread excluding words like 'urgent' or 'help'. Using a proper title makes it easier for members to help you. This thread has been reported for title modification. Please do not add replies that address the thread title.
|
Quote:
That most likely won't do what (s)he wants anyway. In terms of the password field "blank" usually means nothing, not "any amount of whitespace". A more likely candidate: Code:
grep -E "^..*:..*:..*:..*:[[:space:]]*:.*" /etc/passwd Cheers, Tink |
I hope the below can help you.
Code:
awk -F: '($5 == "") {print}' /etc/passwd |
Quote:
The best description I've found of all the character classes is in the grep info page. |
The isalpha man page is good too
|
Quote:
Don't you hate it when man & info are out of sync like that? :D Thanks for the update. |
Tinkster ,
Thanks for the clarificarion ! |
An answer but not grep
#!/bin/bash
for j in $(cut -f "some numbers defining the text positions in -f": /etc/password) Page 162 in Learning the bash shell by Cameron Newham & Bill Rosenblatt. Your answer is there. I I have helped in any way give me a pat on the back (add to my reputation) Learn the Bash shell and all will be well. If I have helped you in any way give me a pat on the back (add to my reputation) D |
All times are GMT -5. The time now is 09:49 PM. |