LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 04-19-2013, 02:02 AM   #1
v11pandey
LQ Newbie
 
Registered: Oct 2012
Posts: 11

Rep: Reputation: Disabled
Need a small script to grep file details from around 2000 files.


Hi,

I have a directory were printer definitions are stored there are more than 2000 printer definitions in it and each printer definition looks as below :-

root@segotl0269# cat qpl00361
*------------------------------------------------------------------------*
* VPSX Printer definition file (QPL00361) *
* Last updated by: Unknown 24 Jul 2012 11:13:43 *
*------------------------------------------------------------------------*
GRPNAME = BUS
ACCT = YES
AUTOEJCT = YES
COMPRESS = YES
COMMTYPE = TCPIP/LPD
DEVTYPE = TXT
ERRACTN = HOLD
MAILCSET = ISO-8859-15
FFSEQ = 0D0C
NLSEQ = 0D0A
RETAIN = 7
SEPAR = N
SEPNAME = default
SNMP = YES
SNMPCOMM = public
TCPHOST = 153.112.40.99
TCPOPTS = 02
TCPPRTR = PRT1
FILTER1 = /opt/lrs/convert1/lrscvdr
F1DTYPE = SAPGOF
F1ARGS = OTF2PCL &KEYOTF2PCL -i &INFILE -o &OUTFILE -type pcl -profilevar colour=false -logdir &TMPDIR -logfile &PRINTER
FILTER2 = /opt/lrs/convert1/lrscvdr
F2DTYPE = SAPGOFU
F2ARGS = OTF2PCL &KEYOTF2PCL -i &INFILE -profilevar SAPCP=4102 -o &OUTFILE -type pcl -profilevar colour=false -logdir &TMPDIR -logfile &PRINTER
EKEY = dynamic
EDEVICE = LRSQUEUE


=======================================

So i want to grep printer name starting with QFRxxx as prefix with IP address for that printer among 2000 printer definitions in the directory.


Thanks in Advance.
 
Old 04-19-2013, 03:21 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
1. show some example output you want
2. looks like the filename is the same as the printer name, so search by filename then grep for the IP (I'm assuming you want the TCPHOST field).
3. write some code and test it; come back if you get stuck and show us your code.

In the meantime, you'll want these
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
Old 04-19-2013, 04:25 AM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Can't you simply grep it, as:
Code:
~$ grep 'QFR*' qpl00361
OR
~$ awk '/QFR/ && /TCPHOST/ {print $0}' qpl00361
And as Chris said, be little specific and show us some example, so people could suggest something helpful.

PS: Please use [code][code] around command and output that you share.

Last edited by shivaa; 04-19-2013 at 04:27 AM.
 
Old 04-19-2013, 04:39 AM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,104

Rep: Reputation: 181Reputation: 181
check out this thread:
http://www.linuxquestions.org/questi...e-grep-819347/

or you can use vi editor to search

vi qpl00361

:s/QFR/
 
Old 04-19-2013, 04:56 AM   #5
v11pandey
LQ Newbie
 
Registered: Oct 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
Thanks Chris and Shiva for the suggestion and link..
Going through those
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script to grep using one file and create files using another file samanp Programming 4 08-22-2012 10:27 PM
[SOLVED] store the files details in different different file using bash anishkumarv Linux - Newbie 4 03-20-2011 10:44 AM
Script to grep log files based on system date cyclegar Programming 2 05-05-2009 07:08 PM
How to create new log file to store details of the accessed files..! hsatish Linux - Newbie 6 01-22-2009 01:22 AM
script to grep lines out of a file qipman Linux - General 5 09-26-2007 01:01 PM


All times are GMT -5. The time now is 08:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration