- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk or other command help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 10:57 AM
тАО03-03-2010 10:57 AM
I am trying to figure out if a user is part of a group or not for many servers. I have a repository of the servers at a central location /tmp/type/*/group.
Where type is variable and * are hundres of servers i.e. /tmp/servers/JRA/*/group.
I want to check if ID JRA is a part of group JRA_W on all of these servers. Can someone help me with a single command to achieve this.
Thanks in advance!
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 11:05 AM
тАО03-03-2010 11:05 AM
Re: awk or other command help
This might be as simple as :
# awk '/JRA/ && /^JRA_W:/' {print FILENAME":",$0}' /tmp/type/*/group
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 11:13 AM
тАО03-03-2010 11:13 AM
Re: awk or other command help
When I try this it gets me a
>
What does the FILENAME does in the code.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 11:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 11:29 AM
тАО03-03-2010 11:29 AM
Re: awk or other command help
Sorry a typo. The command should be:
# awk '/JRA/ && /^JRA_W:/ {print FILENAME":",$0}' /tmp/type/*/group
The 'FILENAME' is 'awk's current file name being processed. This adds the name of the file that has matching criteria to the output followed by a colon and the line that matched.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 11:34 AM
тАО03-03-2010 11:34 AM
Re: awk or other command help
I only need to find the servers where JRA ID is not a part of JRA_W group so that I can add it to the group. This currently gives me everything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 11:39 AM
тАО03-03-2010 11:39 AM
Re: awk or other command help
awk '!/JRA/ && /^JRA_W:/ {print FILENAME":",$0}' /tmp/type/*/group
This should give you the files where JRA is NOT part of JRA_W.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 11:44 AM
тАО03-03-2010 11:44 AM
Re: awk or other command help
> I only need to find the servers where JRA ID is not a part of JRA_W group so that I can add it to the group. This currently gives me everything.
Then:
# awk '/^JRA_W:/ && !/JRA/ {print FILENAME}' /tmp/type/*/group | sort -u
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2010 11:52 AM
тАО03-03-2010 11:52 AM