Linux - Newbie This 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.
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-10-2012, 05:49 AM
|
#1
|
|
LQ Newbie
Registered: Dec 2012
Posts: 9
Rep: 
|
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.
|
|
|
|
12-10-2012, 06:16 AM
|
#2
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,718
|
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.
|
|
|
|
12-10-2012, 06:26 AM
|
#3
|
|
LQ Newbie
Registered: Dec 2012
Posts: 9
Original Poster
Rep: 
|
Home schooling
Quote:
Originally Posted by druuna
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
|
|
|
|
12-10-2012, 06:36 AM
|
#4
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,718
|
Using grep:
Code:
grep "^.*a.*:x:" /etc/passwd
or, using awk (probably preferable):
Code:
awk -F: '$1 ~ "a" { print }' /etc/passwd
|
|
|
|
12-10-2012, 06:44 AM
|
#5
|
|
LQ Newbie
Registered: Dec 2012
Posts: 9
Original Poster
Rep: 
|
Reply
Quote:
Originally Posted by druuna
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
|
|
|
|
12-10-2012, 07:03 AM
|
#6
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,718
|
I used an a instead of a w in my example.
|
|
|
1 members found this post helpful.
|
12-10-2012, 07:07 AM
|
#7
|
|
LQ Newbie
Registered: Dec 2012
Posts: 9
Original Poster
Rep: 
|
Thank
Thanks drunna. I appreciate
|
|
|
|
12-10-2012, 09:11 AM
|
#8
|
|
Senior Member
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,636
|
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. 
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:44 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
|
|