Solved

grep

Posted on 2001-07-10
2
355 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

21 Experts available now in Live!

Get 1:1 Help Now