Sponsored Content
Top Forums Shell Programming and Scripting Script to process file from a directory and grep the required content and print Post 302767313 by Optimus81 on Wednesday 6th of February 2013 04:00:52 PM
Old 02-06-2013
Script to process file from a directory and grep the required content and print

Hi All,
below script reads the perticular files from the directory. Am trying to fetch status and print them in the required format.
It needs to read line and search for string "Passed/Failed" and print them under correct sub header.

script :
Code:
 
BASE_DIR=/tmp/test/REPORT/CollectReport
# report header.
echo
echo "Server              Interface Checks                  Process Checks          Service Check"
echo "              VerifyInterface  Corefile      VerifyRegister VerifyComponent                "
echo "-------      ----------------  ---------     -------------  -------------     -------------"
#cd $BASE_DIR
 
for file in *_Daily_Check*
    do
      if [ -f "$file" ];then
       awk -F":" '/[Pp]assed/{print $3 $1 FS}' "$file"
       awk -F":" '/[Ff]ailed/{print $3 $1 FS}' "$file"
       echo "$file"
      fi
    done

Code:
 
Input file looks like
Code:
root@bbt #  cat D01B_Daily_Check.log
 
1.Interface checking
 
Passed:VerifyInterface:D01B : All interface cards are up
 
Passed:CoreFileGenerated:D01B : There is no core dump file.
 
2.Process checking
 
        Passed:VerifyRegister:D01B : All products have been REGISTERED
 
        Failed:VerifyComponent:D01B : Some Component Not RUNNING.  dbt 0/1 :
 
3.Checking Service available
 
Failed:VerifyServiceAvailability:D01B: Service PERM_DRV is NOT up.
 
root@bbt #  cat E01A_Daily_Check.log
 
1.Interface checking
 
Failed:VerifyInterface:E01A : All interface cards are down
 
Passed:CoreFileGenerated:E01A : There is no core dump file.
 
2.Process checking
 
        Failed:VerifyRegister:E01A : Not all products have been REGISTERED yet
 
        Failed:VerifyComponent:E01A : Some Component Not RUNNING.  dbt 0/1 :
 
3.Checking Service available
 
Failed:VerifyServiceAvailability:E01A: Service PERM_DRV is NOT up.
 
root@bbt #
output required :
Code:
Server              Interface Checks                  Process Checks          Service Check
              VerifyInterface  Corefile      VerifyRegister VerifyComponent                
-------      ----------------  ---------     -------------  -------------     -------------
D01B   Passed   Passed   Passed   Failed   Failed
E01A   Failed   Passed   Failed   Failed   Failed
output now getting like this : root@btt # ./output.sh Server Interface Checks Process Checks Service Check VerifyInterface Corefile VerifyRegister VerifyComponent ------- ---------------- --------- ------------- ------------- ------------- D01B Passed: D01B Passed: D01B Passed: D01B Failed: D01BFailed: D01B_Daily_Check.log E01A Failed: E01A Passed: E01A Failed: E01A Failed: E01AFailed: E01A_Daily_Check.log

 

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
GETINFO(1)						      General Commands Manual							GETINFO(1)

NAME
getinfo - get header information from a RADIANCE file SYNOPSIS
getinfo [ -d ][ file .. ] getinfo - DESCRIPTION
Getinfo reads the header of each RADIANCE file and writes it to the standard output. Octree and picture files are in a binary format, which makes it difficult to determine their content. Therefore, a few lines of text are placed at the beginning of each file by the RADI- ANCE program that creates it. The end of the header information and the start of the data is indicated by an empty line. The -d option can be used to print the dimensions of an octree or picture file instead. For an octree, getinfo -d prints the bounding cube (xmin ymin zmin size). For a picture, getinfo -d prints the y and x resolution (-Y yres +X xres). If no file is given, the standard input is read. The second form of getinfo with a hyphen simply removes the header and copies the body of the file from the standard input to the standard output. EXAMPLE
To print the header information from scene1.oct and scene2.hdr: getinfo scene1.oct scene2.hdr AUTHOR
Greg Ward SEE ALSO
oconv(1), pfilt(1), rhinfo(1), rpict(1), rvu(1) RADIANCE
1/15/99 GETINFO(1)
All times are GMT -4. The time now is 09:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy