Please help in creating search script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help in creating search script
# 1  
Old 07-05-2011
Please help in creating search script

Hi all,

Hope everyone is doing fine. I need a help in creating search script. I have file which contains job names and job recs. I need to select specific job name and next line which is job rec

Code:
 job (BLREEXTT) {
     Record B${cycle}${month}${year}000075;
     follows BLCYRRTCHKT;
     HOST BL_HOST ; }
 job (BLPIEXTT) {
     Record B${cycle}${month}${year}000075;
     follows BLPIHNDLT,BLCYRRTCHKT;
     HOST BL_HOST ; }
 job (BLSRVAGREXTT) {
     Record B${cycle}${month}${year}${paralleltitanbl}0075;
     follows BLCYRRTT;
     HOST BL_HOST ; }

So basicaly file contains many enteries like this. I need to select (in bold ) job which is an easy part and next line. I can grep for job, but how to select line after that. Note that 000075 is changing in the file.

Last edited by pludi; 07-05-2011 at 12:13 PM..
# 2  
Old 07-05-2011
If you are on Linux then this should work:
Code:
grep -A1 "BLPIEXTT" file

# 3  
Old 07-05-2011
Thanks for the fast reply
I'm using Unix but not sure which version.
grep: illegal option -- A
So I'm assuming that I can't use -A on my version
# 4  
Old 07-05-2011
Check on what system you are with:
Code:
uname -a

(post the output here). Anyway this might work on your Unix:
Code:
awk '/BLPIEXTT/{print;getline;print}' file

This User Gave Thanks to bartus11 For This Post:
# 5  
Old 07-05-2011
For this simple scenario, a bit of sed:

Code:
$ sed -n "/BLPIEXTT/{N;p;}" file
 job (BLPIEXTT) {
     Record B${cycle}${month}${year}000075;

(works on Solaris 8 - so should work everywhere!!)
This User Gave Thanks to Scott For This Post:
# 6  
Old 07-05-2011
One more time,

Thanks guys you saved me a bunch of time. Very appriciate it!!!!

We can close this disccusion, not really sure how to do it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with creating a script

Hi everyone, I am completely new to this forum and I have some questions regarding a script I am writing. I would be happy if anyone could help me with the small and precise script which should include if, then, else, while until, case and select. The scenario is as follows: 1) A user... (3 Replies)
Discussion started by: codenotfound
3 Replies

2. Shell Programming and Scripting

Creating IN list in PLSQL script dynamically by using shell script

Hi all, I have a PLSQL script which has a IN list where it takes some ids as input. For example SELECT * FROM EMPLOYEE WHERE EMPLOYEE_ID IN (comma separated list ) I want to run this quest inside a shell script but I would like to prepare the IN list dynamically where the employee ids... (1 Reply)
Discussion started by: LoneRanger
1 Replies

3. Shell Programming and Scripting

Need help in creating file restoration script from a backup script.

Hi all i am struggling in creating a restore of env files while doing applications clone. the first file i created for copying the important configurations file which is running perfect now for reverting the changes i mean when i am restoring these files to its original places i have to do... (7 Replies)
Discussion started by: javeedkaleem
7 Replies

4. UNIX for Dummies Questions & Answers

Creating a script

Alright, well I did some more research since I originally posted this thread, and as much as I'd like to delete it, I can't, so I'll just extend my initial question a little. Right now I have 3 scripts: 1#!/bin/bash # script1 - Write all files modfied x days ago find .. -daystart -mtime 0... (2 Replies)
Discussion started by: Aussiemick
2 Replies

5. Programming

need help with creating a sh script

Hi everyone I’m not a programmer and my knowledge of scripting is very poor, now I’m stock in a task at work and would really appreciate it if someone could help me out. Here is the problem: 1. I have a file with 9 million entries that look like this : 611424167 610864581 611881523 609585386... (3 Replies)
Discussion started by: hiker1064
3 Replies

6. Homework & Coursework Questions

creating search script for a text file

I am aware of the stipulations regarding homework, however I am completely stuck and do not know how to even begin the following (in bash): Create a script that searches for a text file with most occurrences of a given keyword. Any help is greatly appreciated. Thank you (1 Reply)
Discussion started by: hybridoutlaw
1 Replies

7. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

8. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

9. Shell Programming and Scripting

Need help creating a script

I need to automate the following process: I have a list of ip address for printers in a file called iplist.txt, I need to take that list and run the command snmpget -v 1 -c public ip address sysName.0 for each ip address to see if the printer is running snmp, I want to the create a file... (4 Replies)
Discussion started by: inLine6
4 Replies

10. Programming

creating a new C script

All right. Heres the deal, I need to know everysingle command or funtion there is to create a new c file (file.c). Heres the catch: I cannot use text editors!!!:mad: I heard of a "gcc" command is that any good?:confused: Thanks..:cool: (2 Replies)
Discussion started by: AbRa-KaDabRa
2 Replies
Login or Register to Ask a Question