LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Display users with symbol 'w' (https://www.linuxquestions.org/questions/linux-newbie-8/display-users-with-symbol-w-4175440790/)

danieella 12-10-2012 05:49 AM

Display users with symbol 'w'
 
Hello everyone. Please i need your help to display users in a system that contain 'W' symbol in their name and store the information in a file. Thank you

'cat /etc/passwd' just display all users.

druuna 12-10-2012 06:16 AM

This looks a bit like homework to me, so I'm going to provide a hint:

The grep command comes to mind. You do need to be careful and write a regular expression that only looks at the username field.

danieella 12-10-2012 06:26 AM

Home schooling
 
Quote:

Originally Posted by druuna (Post 4846161)
This looks a bit like homework to me, so I'm going to provide a hint:

The grep command comes to mind. You do need to be careful and write a regular expression that only looks at the username field.

I am learning to use putty and answering questions randomly
I know cat /etc/passwd display all users. I need to know how to filter by displaying users with a particular character or symbol in their name. Thanks

druuna 12-10-2012 06:36 AM

Using grep:
Code:

grep "^.*a.*:x:" /etc/passwd
or, using awk (probably preferable):
Code:

awk -F: '$1 ~ "a" { print }' /etc/passwd

danieella 12-10-2012 06:44 AM

Reply
 
Quote:

Originally Posted by druuna (Post 4846182)
Using grep:
Code:

grep "^.*a.*:x:" /etc/passwd
or, using awk (probably preferable):
Code:

awk -F: '$1 ~ "a" { print }' /etc/passwd

Using putty. The above command doesnt seem to work in putty

druuna 12-10-2012 07:03 AM

I used an a instead of a w in my example.

danieella 12-10-2012 07:07 AM

Thank
 
Thanks drunna. I appreciate

shivaa 12-10-2012 09:11 AM

Quote:

Using putty. The above command doesnt seem to work in putty...
Putty is a terminal emulator, not command interpretter. Commands are specific to your OS or working shell, not to any tool like Putty. Same command will work in every tool if used in same OS and shell. :)


All times are GMT -5. The time now is 08:01 PM.