Shell Script Needed to Read a text from a list files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script Needed to Read a text from a list files
# 1  
Old 11-13-2009
Shell Script Needed to Read a text from a list files

Hi,

Below is my issue which I desperately need and I want a shell script which can do this job.

I need this script as I m planning to put this for a system health check. Please assist me.

1. There are 10 log files in a particular location.

2. open each log file. Goto to the end of the file. From the end go up to find a particular text. From this particular text till the end of the log search for another particular text.

3. if the particular text exists in the file return the file name(s) as the output.

Please help me with the script. Thanks a lot to all.

Thanks and Regards
Shriram
# 2  
Old 11-13-2009
I think you're question is worded strangly, but based on what I think you want:

Code:
awk '
  /find1/ { P = 1 }
  P && /find2/ { print FILENAME; P = 0; nextfile}
' file*

Replace file* with your list of filenames, and find1 and find2 based on what you're looking for.
# 3  
Old 11-13-2009
I agree the request is hard to understand but I think what is needed:
Code:
awk '/pattern 1/ {line1=FNR} 
                   /pattern 2/ {line2=FNR} 
                   END { if(line1 < line2) 
                             {print FILENAME}
                           }'  *.logfile > reportfile

where pattern1 is the first text pattern to find and pattern2 is the second pattern.
# 4  
Old 11-13-2009
Oh, I see what you mean.
# 5  
Old 11-13-2009
Thanks a lot for your help, support and time. I will try this command and will get back shortly. Once again Thanks a LOT.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script needed for comparing two files

Hi, I need shell script to compare the two files based on certain fields and output should contains the required fields based on result.pls find sample input files and required output file 1 COUNT, BNG_IP,PORT,OVLAN 22 , 10.238.60.129,1/1,2009 144 , 10.238.60.129,1/1,2251 ... (5 Replies)
Discussion started by: surender reddy
5 Replies

2. Shell Programming and Scripting

Needed shell script to append desired text to each line in a file

Hi, I had generated a report in my tool as followsoutput.txt 43.35 9 i needed the script to generate a new file like below i want to append the text to each of these lines of my filenewoutputfile.txt should be Total Amount : 43.35 Record Count:9 Regards, Vasa Saikumar. ... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

3. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

4. Shell Programming and Scripting

Needed shell script to read txt file and do some modification

Hi ...programmers... I need a shell script to perform some specific task.. my txt file looks like this netcdf new { dimensions: XAX1_11 = 11 ; variables: double XAX1_11(XAX1_11) ; XAX1_11:point_spacing = "even" ; XAX1_11:axis = "X" ; float DEPTH(XAX1_11) ;... (19 Replies)
Discussion started by: Akshay Hegde
19 Replies

5. Shell Programming and Scripting

Script help needed(lookup 2 text files)

Hi, iam new to unix scripting need a help. The scenario is i have 2 text files. a.txt has colA colB colC colD JKU1270A JKU1042A 9 1 JKU1270A JKU1042B 9 1 JKU1270A JKU1042C 9 1 JKU1270B JKU1107B 9 1 JKU1270B JKU1107C 9 1... (1 Reply)
Discussion started by: tech_frk
1 Replies

6. Shell Programming and Scripting

how to read two text files in the same shell script

Folks i have written two scripts that do reading of csv files , i am currently fetching the all part of the line in to variables and braking the line into several variables. I am doing the same thing in an another shell script, i want to integrate both the scripts in to a single one where i can... (2 Replies)
Discussion started by: venu
2 Replies

7. Shell Programming and Scripting

How to read the data from the text file in shell script?

I am having one text file and i need to read that data from my shell script. I will expain you the scenario: Script look like: For name type 1: For age type 2: For Salary type3: echo "Enter the input:" read the data if input is 1 then go to the Text file and print the... (2 Replies)
Discussion started by: dineshmurs
2 Replies

8. Shell Programming and Scripting

URGENT: Script/Function needed to read text property files in block wise

Hi, Iam in a need for a script/function in KSH where I want to read a text file (property file) in block by block. Here is the example: Heading Name Descripton Block Block1 Value1 Description Property Name Value Property Name Value Property Name Value Property Name Value Property Name... (7 Replies)
Discussion started by: ysreenivas
7 Replies

9. Shell Programming and Scripting

help needed in a shell script for printing files

Hi All, I am writing a shell script to print all the files in a particular folder. This script is on solaris server . I am using the lp command to send the requests . lp -d printername filename . The output I get is the request id. Is there any way I can use the request Id to determine if... (1 Reply)
Discussion started by: shahshilpa
1 Replies

10. Shell Programming and Scripting

read list of filenames from text file and remove these files in multiple directories

I have a large list of filenames from an Excel sheet, which I then translate into a simple text file. I'd like to use this list, which contains various file extensions , to archive these files and then remove them recursively through multiple directories and subdirectories. So far, it looks like... (5 Replies)
Discussion started by: fxvisions
5 Replies
Login or Register to Ask a Question