Sponsored Content
Full Discussion: Search script
Top Forums Shell Programming and Scripting Search script Post 97802 by BCarlson on Thursday 2nd of February 2006 01:28:12 PM
Old 02-02-2006
Search script

I need to create a script called 'find_data' that will search a file by passing two parameters to it Smilie . I'm pretty good with scripting but haven't really gotten into sed and awk that much (and no perl whatsoever). I'm really at a loss and need to get something working in the next couple days (yes, we still do work on weekends).

The script should work like this.

find_data <parameter 1> <parameter 2>

The first parameter would be the data before the colon (':').
The second parameter would be the data after the colon (':')
If both are found the data between the preceeding BEGINJOB and ENDJOB (inclusive) should be displayed to stdout.

Examples using the data:

1 find_data start 01:15 would find, and display, the first set of data.
2 find_data days tu would find, and display, the last set of data.
3 find_data days all would find, and display, the 2nd, 3rd and 4th sets of data.

I really appreciate your help with this. It's a great site.



Sample data (only five shown but there are several hundred):

BEGINJOB---------------------------
insert_job: cir_cdezp07b job_type: c
command: /apps/usr/circ/bin/cdezp07b.cmd
days_of_week: all
start_times: "01:15"
description: "Mass Zip Code Update"
ENDJOB
BEGINJOB---------------------------
insert_job: cir_ccsds03b job_type: c
command: /apps/usr/circ/bin/ccsds03b.cmd
days_of_week: all
start_times: "02:00"
description: "Deletes Info. from Dispatch_table"
ENDJOB
BEGINJOB---------------------------
insert_job: cir_ccsda78r job_type: c
command: /apps/usr/circ/bin/ccsda78r.cmd REP
days_of_week: all
start_times: "03:00"
description: "Daily Reports"
ENDJOB
BEGINJOB---------------------------
insert_job: cir_ccsda95i job_type: c
command: /apps/usr/circ/bin/ccsda95i.cmd 6 1000 0 25
days_of_week: all
start_times: "04:00"
condition: s (cir_ccbdd01b_daily) & s (cir_ccbdd01b_sat) & s (cir_ccbdd01b_sun)
description: "Archive job, runs M-SU"
ENDJOB
BEGINJOB---------------------------
insert_job: cir_cdtsm01i job_type: c
command: /apps/usr/circ/bin/cdtsm01i.cmd
days_of_week: tu,we,th,fr,sa
start_times: "04:00"
description: "Templated Solo Mail - aoets20b.tx to aoets20b_txt"
ENDJOB
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to search all the directories

Hi there, Is there any command or script to search all the directories for duplicated files? Thanks, Abrahim (3 Replies)
Discussion started by: abk
3 Replies

2. Shell Programming and Scripting

Search File Script

Nice forum for noobs like me to UNIX. With that said, I need assistance. I am trying to make a script to search files for a specific date and string within the file. Then I need the script to move the file that have the specific date and string to a directory. In the interim I have been manually... (7 Replies)
Discussion started by: I4ce
7 Replies

3. UNIX for Advanced & Expert Users

Help with search script

HI all, I am trying to find files that have .cc3 file extenstion folder using this script below, but this fails as there are files in the folder and i get a message saying i have no files. Please anyone reveiw and let me know if i am missing anything.I am working on this from two days and i... (9 Replies)
Discussion started by: bsandeep_80
9 Replies

4. Shell Programming and Scripting

script to search a file

hi all i have a requirement to write a script which will serach a file in a particuar location for 3 hours from the time when the script is run.if during this period the file arrives in a particular location then this will transmit the file to a other server.please help me writing the script which... (1 Reply)
Discussion started by: dr46014
1 Replies

5. Shell Programming and Scripting

Small Search script

I need to write a small shell script which does the following : I have a file : root/var/log/ocmp/ocmpclient.log This is a log file which is continuosly getting updated . I have to keep looking into this file all the time. I have to look for four keywords, "File Detected", File Sending",... (2 Replies)
Discussion started by: appu1987
2 Replies

6. Shell Programming and Scripting

Log Search Script

Hi, I am trying to write a script to search a log- IPaddress being the search criteria, I would ideally like the script to ask the ipaddress Enter IP address - 244.258.27.225 And the ideal result would be for the script to get all the entries in the log file for a particular IP address,... (3 Replies)
Discussion started by: fuzion.hyd
3 Replies

7. Shell Programming and Scripting

Search and Copy Script

Dear All, I would like to create a Unix script which basically searches for files which are more than 2 days old and copy only the new files to the destination. What i mean is if the destination may have most of the files, it may not have only last 2 to 3 days file. I am able to create the... (6 Replies)
Discussion started by: rrb2009
6 Replies

8. Shell Programming and Scripting

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 job (BLREEXTT) { Record B${cycle}${month}${year}000075; follows BLCYRRTCHKT; ... (5 Replies)
Discussion started by: taksistalo
5 Replies

9. UNIX for Dummies Questions & Answers

Help with ip search script

Hi Obviously first time poster here. I have been set the task of creating a network diagram for each of our clients in the business i work for. After identifying ip adresses of firewalls name servers and the like im got to the point where i found it impracticle to go through 254 ip address and... (6 Replies)
Discussion started by: jeked
6 Replies

10. Shell Programming and Scripting

Timebased search script

Hi there first of all, sry for my bad english and possible mistakes .-) I write scripts for my server to get my live easier. So my next one will be a script, where I can find special files in a folder. I put with a script of mine files in a folder on the server with following name... (5 Replies)
Discussion started by: bigsanch
5 Replies
shells(4)							   File Formats 							 shells(4)

NAME
shells - shell database SYNOPSIS
/etc/shells DESCRIPTION
The shells file contains a list of the shells on the system. Applications use this file to determine whether a shell is valid. See getuser- shell(3C). For each shell a single line should be present, consisting of the shell's path, relative to root. A hash mark (#) indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. The following default shells are used by utilities: /bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh, /sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh. Note that /etc/shells overrides the default list. Invalid shells in /etc/shells may cause unexpected behavior (such as being unable to log in by way of ftp(1)). FILES
/etc/shells lists shells on system SEE ALSO
vipw(1B), ftpd(1M), sendmail(1M), getusershell(3C), aliases(4) SunOS 5.10 4 Jun 2001 shells(4)
All times are GMT -4. The time now is 10:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy