Sponsored Content
Top Forums Shell Programming and Scripting Script to process file from a directory and grep the required content and print Post 302767741 by Yoda on Thursday 7th of February 2013 11:22:49 AM
Old 02-07-2013
Code:
for file in *_Daily_Check*
do
        server=${file%%_*}
        if [ -f "$file" ]
        then
                awk -F":" -v S="$server" '/VerifyInterface/ {
                        if($1=="Passed") s="\033[1;32m" $1 "\033[0m";
                        if($1=="Failed") s="\033[1;31m" $1 "\033[0m";
                        printf "%s\t\t%s", S, s;
                } /CoreFileGenerated/ {
                        if($1=="Passed") s="\033[1;32m" $1 "\033[0m";
                        if($1=="Failed") s="\033[1;31m" $1 "\033[0m";
                        printf "\t\t%s", s;
                } /VerifyRegister/ {
                        if($1=="Passed") s="\033[1;32m" $1 "\033[0m";
                        if($1=="Failed") s="\033[1;31m" $1 "\033[0m";
                        printf "\t\t%s", s;
                } /VerifyComponent/ {
                        if($1=="Passed") s="\033[1;32m" $1 "\033[0m";
                        if($1=="Failed") s="\033[1;31m" $1 "\033[0m";
                        printf "\t\t%s", s;
                } /VerifyServiceAvailability/ {
                        if($1=="Passed") s="\033[1;32m" $1 "\033[0m";
                        if($1=="Failed") s="\033[1;31m" $1 "\033[0m";
                        printf "\t\t%s\n", s;
                } ' "$file"
        fi
done

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to search content of file with timestamps in the directory

hello, i want to make a script to search the file contents in my home directory by a given date and output me the line that has the date... (10 Replies)
Discussion started by: psychobeauty
10 Replies

2. UNIX for Dummies Questions & Answers

Print the content of a directory in jpg file

Is there any possible way to print the contents of a directory to a .jpg file? I have a list of thumbnails (e-books) which I want to share (+500) but I don't know how to make this. I would appreciate a lot any comments regarding this issue. (4 Replies)
Discussion started by: agasamapetilon
4 Replies

3. Shell Programming and Scripting

Goto each directory and subdirectories and grep the required pattern

Hi All, I need your help in finding pattern from files present in different directories. I need to search for a pattern "xyz" from "*.txt" files which are present in different levels of directories as shown. example ------- dir1/subdir1/file.txt dir2/subdir2/subsubdir2/file.txt... (5 Replies)
Discussion started by: imas
5 Replies

4. Shell Programming and Scripting

Shell script to monitor new file in a directory and mail the file content

Hi I am looking for a help in designing a bash script on linux which can do below:- 1) Look in a specific directory for any new files 2) Mail the content of the new file Appreciate any help Regards Neha (5 Replies)
Discussion started by: neha0785
5 Replies

5. Shell Programming and Scripting

Bash script to read a file from particular line till required line and process

Hi All, Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool. Wraper script am trying is to do with above metion 2 files. utility tool accepts : a. userinfo file : which contains username b. item file : which... (2 Replies)
Discussion started by: Optimus81
2 Replies

6. Shell Programming and Scripting

How to Modify a file content in UNIX and sort for only required fields ?

I have the below contents in a file after making the below curl call curl ... | grep -E "state|Rno" | paste -sd',\n' | grep "Disconnected" > test "state" : "Disconnected",, "Rno" : "5554f1d2" "state" : "Disconnected",, "Rno" : "10587563" "state" : "Disconnected",, "Rno" :... (2 Replies)
Discussion started by: Vaibhav H
2 Replies

7. Shell Programming and Scripting

Help required to Print Single quote into a file

Hi, I need help in printing string enclosed with single quotes to a file. I am trying to write a shell script which when run will create another script below is the script logic. cat create_script.sh echo '#!/bin/sh' > append_flname.sh echo 'for FILE in $*' >> append_flname.sh echo... (6 Replies)
Discussion started by: imrandec85
6 Replies

8. Shell Programming and Scripting

Script to search every file in a directory and print last few lines

Hi everyone, I need to write a script to search a directory, output the name of a file to an ouput file and print the last few lines of the files to the output file such that I would have something like this: FILE1: LINE LINE LINE FILE2: LINE LINE LINE FILE3: LINE LINE LINE... (2 Replies)
Discussion started by: mojoman
2 Replies

9. Shell Programming and Scripting

Directory containing files,Print names of the files in the directory that are exactly same content.

Given a directory containing say a few thousand files, please output a list of all the names of the files in the directory that are exactly the same, i.e. have the same contents. func(a_directory_name) output -> {“matches”: , ... ]} e.g. func(“/home/my/files”) where the directory... (7 Replies)
Discussion started by: anuragpgtgerman
7 Replies
TAP::Parser::Aggregator(3pm)				 Perl Programmers Reference Guide			      TAP::Parser::Aggregator(3pm)

NAME
TAP::Parser::Aggregator - Aggregate TAP::Parser results VERSION
Version 3.23 SYNOPSIS
use TAP::Parser::Aggregator; my $aggregate = TAP::Parser::Aggregator->new; $aggregate->add( 't/00-load.t', $load_parser ); $aggregate->add( 't/10-lex.t', $lex_parser ); my $summary = <<'END_SUMMARY'; Passed: %s Failed: %s Unexpectedly succeeded: %s END_SUMMARY printf $summary, scalar $aggregate->passed, scalar $aggregate->failed, scalar $aggregate->todo_passed; DESCRIPTION
"TAP::Parser::Aggregator" collects parser objects and allows reporting/querying their aggregate results. METHODS
Class Methods "new" my $aggregate = TAP::Parser::Aggregator->new; Returns a new "TAP::Parser::Aggregator" object. Instance Methods "add" $aggregate->add( $description => $parser ); The $description is usually a test file name (but only by convention.) It is used as a unique identifier (see e.g. "parsers".) Reusing a description is a fatal error. The $parser is a TAP::Parser object. "parsers" my $count = $aggregate->parsers; my @parsers = $aggregate->parsers; my @parsers = $aggregate->parsers(@descriptions); In scalar context without arguments, this method returns the number of parsers aggregated. In list context without arguments, returns the parsers in the order they were added. If @descriptions is given, these correspond to the keys used in each call to the add() method. Returns an array of the requested parsers (in the requested order) in list context or an array reference in scalar context. Requesting an unknown identifier is a fatal error. "descriptions" Get an array of descriptions in the order in which they were added to the aggregator. "start" Call "start" immediately before adding any results to the aggregator. Among other times it records the start time for the test run. "stop" Call "stop" immediately after adding all test results to the aggregator. "elapsed" Elapsed returns a Benchmark object that represents the running time of the aggregated tests. In order for "elapsed" to be valid you must call "start" before running the tests and "stop" immediately afterwards. "elapsed_timestr" Returns a formatted string representing the runtime returned by "elapsed()". This lets the caller not worry about Benchmark. "all_passed" Return true if all the tests passed and no parse errors were detected. "get_status" Get a single word describing the status of the aggregated tests. Depending on the outcome of the tests returns 'PASS', 'FAIL' or 'NOTESTS'. This token is understood by CPAN::Reporter. Summary methods Each of the following methods will return the total number of corresponding tests if called in scalar context. If called in list context, returns the descriptions of the parsers which contain the corresponding tests (see "add" for an explanation of description. o failed o parse_errors o passed o planned o skipped o todo o todo_passed o wait o exit For example, to find out how many tests unexpectedly succeeded (TODO tests which passed when they shouldn't): my $count = $aggregate->todo_passed; my @descriptions = $aggregate->todo_passed; Note that "wait" and "exit" are the totals of the wait and exit statuses of each of the tests. These values are totalled only to provide a true value if any of them are non-zero. "total" my $tests_run = $aggregate->total; Returns the total number of tests run. "has_problems" if ( $parser->has_problems ) { ... } Identical to "has_errors", but also returns true if any TODO tests unexpectedly succeeded. This is more akin to "warnings". "has_errors" if ( $parser->has_errors ) { ... } Returns true if any of the parsers failed. This includes: o Failed tests o Parse errors o Bad exit or wait status "todo_failed" # deprecated in favor of 'todo_passed'. This method was horribly misnamed. This was a badly misnamed method. It indicates which TODO tests unexpectedly succeeded. Will now issue a warning and call "todo_passed". See Also TAP::Parser TAP::Harness perl v5.16.2 2012-10-25 TAP::Parser::Aggregator(3pm)
All times are GMT -4. The time now is 01:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy