Solved

grep

Posted on 2001-07-10
2
359 Views
Last Modified: 2012-06-27
I am using grep to get print options from the same line the name of a printer is found on in a file.  In some files the name of the printer may appear two or more times.  I need to get the option from the line the the name of the printer on the first occurance only.

Is there a way to modify the below line so it will only get one occurance of the printer option?

printtype=`grep -i ${printname} /usr/local/etc/hbspool.conf | cut -f3 -d" "`

Or is there another way to operate on the $printtype variable after its value is set and get the string up to the first whitespace?

Thanks for your help.
0
Comment
Question by:mzehner
2 Comments
 

Accepted Solution

by:
earthman1968 earned 100 total points
ID: 6269771
If the line you want is always the first one then pipe the output of the grep through the head command Eg:-

printtype=`grep -i {printname} /usr/local/etc/hbspool.conf | cut -f3 -d" " | head -1`
0
 

Expert Comment

by:SpideyMod
ID: 8275941
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now