Sponsored Content
Top Forums Shell Programming and Scripting Script to check the string in a file and print an attribute in the message Post 302997357 by suren424 on Friday 12th of May 2017 03:13:43 AM
Old 05-12-2017
Script to check the string in a file and print an attribute in the message

Hi,

I am new to shell scripting and got a task to complete.

Task is : we have a log file where in i need to traverse through the whole file to check the string "Person Type missing in message" and after that i need to get EMPLID=xxxxxx from the file and print details in a different file.

Below is snippet of the message in log file ( highlighted in color) which i need from the file

Code:
2017-05-09 20:15:51,713 [asyncDelivery111] [ConnectorBean] [] - ConnectorBean/findEventType Attention ::TEAM
The message with Message IDID:414d5120455342459080862020202020632eee58ffe83028is being ignored::For create event type, Person Type missing in messageFind user attributes in next line
{BUSINESS_TITLE=, PER_TYPE=, PayGroupCode=, LaborType=, RehireDate=, WORKSHIFT_CD=, POSITION_NBR=, HRServiceDate=2017-05-30, FIRST_NAME=xxxx, PeopleSoftID=, HOME_EMAIL_ADDRESS=, JOB_DESCRIPTION=, PER_STATUS=, FAX=, HOME_PHONE=, COMPANY=, WORK_PHONE=, Work Address Line One=, Country=, LAST_NAME=xxxx, PREF_MIDDLE_NAME=, StatusReason=GENERAL_EVENT_SUBCATEGORY-6-66, MANAGER_ID=, DIVISION=, WorkerTypeName=, PREF_FIRST_NAME=xxx, TMS_DEPT_GRP=, EMPL_CLASS=, MAIL_DROP=, DEPTID=, MatrixManager=, COMPANY_DESCR=, EMAIL_ADDR=, DEPT_DESCR=, DEPT_GROUP_ID=, PREF_LAST_NAME=xxxx, WorkerTypeCode=Team Member, UNION_CD=, BUSINESSCELL=, HRSeniorityDate=2017-05-22, PREF_SUFFIX_NAME=, DIVISION_DESCR=, SOX_TRANSFER_FLAG=N, Zip Code=, JOBCODE=, BadgeID=, GRADE=, EMPL_STATUS=A, NAME_SUFFIX=, Work Addrress Line Two=, City=, LOCATION=, LOCATION_DESCR=, JobLevel=, State=, MOBILE=, MIDDLE_NAME=, EMPLID=000112, TMS_PAGER=, REGION_CODE=}

Please let me know, how can i accomplish this.

Thanks in advance

Last edited by Don Cragun; 05-12-2017 at 05:23 AM.. Reason: Add CODE and ICODE tags again.
 

10 More Discussions You Might Find Interesting

1. Linux

File attribute Help please

Could anyone help i have a question that i have a problem with for my home work it is, How do i change file permissions in a command line enviromet thanx (1 Reply)
Discussion started by: Cube3k
1 Replies

2. UNIX for Dummies Questions & Answers

Script to check for a file, check for 2hrs. then quit

I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit. Logically, I'm looking for the best way to approach this Thanks for any assistance in advance. Note: I'm using a C shell and... (2 Replies)
Discussion started by: mmarsh
2 Replies

3. Shell Programming and Scripting

check for not null string in file

Hi, If, in a text file a string is expected at a certain fixed position(for eg at position 5 or from 5-10 on every line) how to check whether data is present on that position or not? Thnx in advance (6 Replies)
Discussion started by: misenkiser
6 Replies

4. Shell Programming and Scripting

bash script to check the first character in string

Hello would appreciate if somebody can post a bash script that checks if the first character of the given string is equal to, say, "a" thnx in advance (2 Replies)
Discussion started by: ole111
2 Replies

5. Shell Programming and Scripting

How to Check given string is number in shell script?

Hi, Can anyone help me out to check whether the input argument is number? Example: REQUEST_ID="123456" I need to check the REQUEST_ID value is number or string. Thanks in Advance Regards BS (6 Replies)
Discussion started by: balajiora
6 Replies

6. Shell Programming and Scripting

Linux Shell Script to check for string inside a file?

This is what I have so far grep -lir "some text" * I need to check all files on the system for this text, if the text is found I need to change the file permissions so only ROOT has read and write access. How can this be done? (3 Replies)
Discussion started by: mapleleafs89
3 Replies

7. Programming

Python: Check 2 text files for string and print contexts

I have 2 text files: cities.txt San Francisco Los Angeles Seattle Dallas master.txt Atlanta is chill and laid-back. I love Los Angeles. Coming to Dallas was the right choice. New York is so busy! San Francisco is fun. Moving to Boston soon! Go to Seattle in the summer. ... (0 Replies)
Discussion started by: pxalpine
0 Replies

8. Shell Programming and Scripting

Check file for string existence before appending it with string

I want to append file with a string but before doing that i want to check if this string already exist in that file.I tried with grep on Solaris 10 but unsuccessful.Man pages from grep seems to suggest if the string is found command status will be 0 and if not 1.But i am not finding it.May be i... (2 Replies)
Discussion started by: sahil_shine
2 Replies

9. Shell Programming and Scripting

Use while loop to read file and use ${file} for both filename input into awk and as string to print

I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix. I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice. Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

10. UNIX for Beginners Questions & Answers

awk script to match string and print status

Dear team, Need support to built awk script for below requirement Input file LOTC cluster state: ------------------- Node safNode=SC_2_1 joined cluster | Node safNode=SC_2_2 joined cluster | Node safNode=PL_2_3 fail cluster | AMF cluster state: ------------------... (16 Replies)
Discussion started by: shanul karim
16 Replies
ATF-SH(1)						    BSD General Commands Manual 						 ATF-SH(1)

NAME
atf-sh [-s shell] -- interpreter for shell-based test programs SYNOPSIS
atf-sh script DESCRIPTION
atf-sh is an interpreter that runs the test program given in script after loading the atf-sh(3) library. atf-sh is not a real interpreter though: it is just a wrapper around the system-wide shell defined by ATF_SHELL. atf-sh executes the inter- preter, loads the atf-sh(3) library and then runs the script. You must consider atf-sh to be a POSIX shell by default and thus should not use any non-standard extensions. The following options are available: -s shell Specifies the shell to use instead of the value provided by ATF_SHELL. ENVIRONMENT
ATF_LIBEXECDIR Overrides the builtin directory where atf-sh is located. Should not be overridden other than for testing purposes. ATF_PKGDATADIR Overrides the builtin directory where libatf-sh.subr is located. Should not be overridden other than for testing purposes. ATF_SHELL Path to the system shell to be used in the generated scripts. Scripts must not rely on this variable being set to select a specific interpreter. EXAMPLES
Scripts using atf-sh(3) should start with: #! /usr/bin/env atf-sh Alternatively, if you want to explicitly choose a shell interpreter, you cannot rely on env(1) to find atf-sh. Instead, you have to hardcode the path to atf-sh in the script and then use the -s option afterwards as a single parameter: #! /path/to/bin/atf-sh -s/bin/bash ENVIRONMENT
ATF_SHELL Path to the system shell to be used in the generated scripts. SEE ALSO
atf-sh(3) BSD
September 27, 2014 BSD
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy