Best way to parse 1000 scripts for a string?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Best way to parse 1000 scripts for a string?
# 8  
Old 05-13-2014
Code:
find . -name "*.ksh" -type f |
while IFS= read -r fname; do
        for i in 1 2; do
                IFS= read -r line
                case $line in
               'exit 0'|'exit 0;')
                        printf '%s\n' "$fname"
                        break
                esac
        done < "$fname"
done

If they're all in the same directory, then find is not needed and the while-loop can be replaced with for fname in *.ksh; ....

This script also has the advantage of never reading past the second line of a file.

Regards,
Alister
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do you check for a particular string in 1000's of files?

Please forgive my ignorance on scripting. I am trying to determine (via a script) if a certain string of characters is present . The string that I am looking for is a constant length. Here is the string I am searching for: Model_Type={t}, ModelName={m} I need to determine if the above... (2 Replies)
Discussion started by: dlundwall
2 Replies

2. Shell Programming and Scripting

parse a mixed alphanumeric string from within a string

Hi, I would like to be able to parse out a substring matching a basic pattern, which is a character followed by 3 or 4 digits (for example S1234 out of a larger string). The main string would just be a filename, like Thisis__the FileName_S1234_ToParse.txt. The filename isn't fixed, but the... (2 Replies)
Discussion started by: keaneMB
2 Replies

3. Shell Programming and Scripting

Script to find the string contain in which file 1000 files.

Hi Greetings i have 1000 files (xmlfiles) and i need to find which file contain the string over 1000 file all file end with txt i tried with grep -c "string" *.txt i am getting an error -bash: /bin/egrep: Argument list too long i have put an script like below #!/bin/bash for line... (9 Replies)
Discussion started by: venikathir
9 Replies

4. Shell Programming and Scripting

Parse string

Hi, I need to parse a string, check if there are periods and strip the string. For example i have the following domains and subdomains: mydomain.com, dev.mydomain.com I need to strip all periods so i have a string without periods or domain extensions: mydomain, devmydomain. I use this for... (12 Replies)
Discussion started by: ktm
12 Replies

5. Shell Programming and Scripting

How to parse a string into variables

I'm working in korn shell and have a variable which contains a string like: aa_yyyymmdd_bbb_ccc_ddd.abc. I want to treat the _ and . as delimiters and parse the string so I end up with 6 values in variables that I can manipulate. My original plan was to use var1=`echo $sting1 | cut -c1-c2` but... (9 Replies)
Discussion started by: aquimby
9 Replies

6. Shell Programming and Scripting

How to parse a string efficiently

I am new to the boards and to shell programming and have a requirement to name new files received with a unique sequence number. I need to look at a particular file pattern that exists and then to increment a sequence by 1 and write the new file. Example of file names and sequence # ... (4 Replies)
Discussion started by: sandiego_coder
4 Replies

7. Shell Programming and Scripting

Parse String Using Sed

Hi, I am wondering if there's a simpler way to extract the second occurrence of a word enclosed in that matches my search criteria. Sample Input is as follows: Error installing feature - com.er.nms.cif.ist.NoMatchingUpgra Error installing feature -... (4 Replies)
Discussion started by: racbern
4 Replies

8. Shell Programming and Scripting

how to parse this string

I want to get filenames from the following input. How can I parse this in bash. input data ------------------------------------------------------------------- path=/aaa/bbb/filename1;/aaa/filename2;/aaa/bbb/ccc/ddd/filename3 -------------------------------------------------------------------... (13 Replies)
Discussion started by: hcliff
13 Replies

9. Shell Programming and Scripting

shell scripts that parse log files

hi all ,i would like a shell script that parses log files and checks the contents for any anonalities,please help,thanks (4 Replies)
Discussion started by: trueman82
4 Replies

10. Shell Programming and Scripting

How to parse large numbers of shell scripts

I am trying to parse hundreds of shell scripts to determine how they related to each other. Ideally for every script, I would get an output of: What other scripts it calls What files it reads Environment variables it accesses Any ideas on how to do this? TIA! (2 Replies)
Discussion started by: bliss
2 Replies
Login or Register to Ask a Question
NSAPI_VIRTUAL(3)							 1							  NSAPI_VIRTUAL(3)

nsapi_virtual - Perform an NSAPI sub-request

SYNOPSIS
bool nsapi_virtual (string $uri) DESCRIPTION
nsapi_virtual(3) is an NSAPI-specific function which is equivalent to <!--#include virtual...--> in SSI ( .shtml files). It does an NSAPI sub-request. It is useful for including CGI scripts or .shtml files, or anything else that you'd parse through webserver. To run the sub-request, all buffers are terminated and flushed to the browser, pending headers are sent too. You cannot make recursive requests with this function to other PHP scripts. If you want to include PHP scripts, use include(3) or require(3). Note This function depends on a undocumented feature of the Netscape/iPlanet/Sun webservers. Use phpinfo(3) to determine if it is avail- able. In the Unix environment it should always work, in Windows it depends on the name of a ns-httpdXX.dll file. Read the note about subrequests in the NSAPI section (UNIX, Windows) if you experience this problem. PARAMETERS
o $uri - The URI of the script. RETURN VALUES
Returns TRUE on success or FALSE on failure. PHP Documentation Group NSAPI_VIRTUAL(3)