- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: help with grep ' :${a[n]}' question
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
Forums
Discussions
Discussions
Discussions
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
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
07-21-2003 09:56 AM
07-21-2003 09:56 AM
I am creating a script (ksh) to match specific users with their displays.
Originally I ran
cat /data/cit_rugby|grep :${a[n]}
but then I found I had the following problem as time also has the colon format.
---
cat /data/cit_rugby|grep :15
user1 6203 6202 0 09:37:15 ? 0:00 /opt/CTXSmf/slib/ctxlogin -display :14
user2 28668 28667 0 17:21:03 ? 0:00 /opt/CTXSmf/slib/ctxlogin -display :15
reading the man pages on grep I tried using quotes ' ' but I was unable to use a variable. Typing the variable in returns the correct answer.
cat /data/cit_rugby|grep ' :15'
user2 28668 28667 0 17:21:03 ? 0:00 /opt/CTXSmf/slib/ctxlogin -display :15
How do I use a variable within the quotes or is there another way to do this.
thanks
Eric
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2003 10:10 AM
07-21-2003 10:10 AM
Solutionto remove the normal meaning that ksh places on | or on any other special character, you must quote it. you can quote a single character by preceding it with a backslash (\).
Literal (single) quotes, '..' removes the special meaning of all characters except '.
Grouping (double) quotes, "...", removes the special meaning of all characters except $,\,and `. if the $ is not quoted, then varialbe substitution is doen inside double quotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2003 10:15 AM
07-21-2003 10:15 AM
Re: help with grep ' :${a[n]}' question
sed '/.*ctxlogin.*:'${a[n]}'/p'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2003 10:20 AM
07-21-2003 10:20 AM
Re: help with grep ' :${a[n]}' question
awk -F: num=${a[n]} '{ if ( $NF == num ) print $0;}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2003 10:27 AM
07-21-2003 10:27 AM
Re: help with grep ' :${a[n]}' question
Are you trying to match users to their processes or what users are using what display devices (which usually a "who -u" will suffice).
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2003 12:15 AM
07-22-2003 12:15 AM
Re: help with grep ' :${a[n]}' question
Eric