Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Script

Status
Not open for further replies.

beaster

Technical User
Aug 20, 2001
225
US
I have a text file that has text in it like that below. I need a small script that reads or cat's this file, alarm.txt

(filename). I need it to give me an output file with only certain info from the file.

***FILE ALARM.TXT***
A1/EXT "BH1MSC C000Q00" 007 011026 0020
COMMERCIAL POWER FAIL



EXTERNAL ALARM
GENERATOR CONTROL SWITCH IN MANUAL.
EXTERNAL CABINET DOOR ALARM.



A3/APT "BH2MSC D000L00" 100 011118 0006
IAN-2 D-CHANNEL FAILURE

DETY
RALT24


If the above alarm.txt file contained the words COMMERCIAL POWER FAIL or IAN-2 D-CHANNEL FAILURE (From which are set up in

another file called alarm_strip which it fgrep's from, I want a seperate output file for each. The output file would need to

be a "one-liner" which I have listed an example below and the file name would have to go up in sequence for each file.

Example would be alarm_ftp1 and alarm_ftp2.

Inside the first file alarm_ftp1 textfile would read:

BH1MSC COMMERCIAL POWER FAIL

Inside the second file alarm_ftp2 textfile would read:

BH2MSC IAN-2 D-CHANNEL FAILURE

So inside the final file, it would have had to fgrep from an input file, searched for the keywords and if it found it, output

it in a particular format while reading which node it was in (BH1MSC or BH2MSC, see above alarm.txt file example) in front of

the text and output them to seperate text files going up in sequence.


I hope I have not bothered anyone by asking for too much.

Beaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top