Sponsored Content
Top Forums Shell Programming and Scripting Help Required For String Matching Post 302459274 by abhigrkist on Monday 4th of October 2010 08:50:25 AM
Old 10-04-2010
Help Required For String Matching

I am new to shell scripting !!!!!!!!!!.ANY HELP WOULD BE APPRECIATE :-
i want to write a script that will check the log for string:
waiting for [10] seconds

for this I am using :-
Code:
tail -10 log.20101004 | tail -1

and grep the "string" but when matching error is coming ,see script below:-

i want to kill that process if matching pattern came,
Code:
LOG_PATH=/temp/circles/ABHI/LOGs
DATE=`date +%Y%m%d`
LOG_NAME=gprs_cdr_parser_log.$DATE
PID=`ps -eaf| grep del_gprs_cdrs_parserd | grep -v 'grep' | awk '{ print $2 }'`
cd $LOG_PATH
VAR=`tail -10 gprs_cdr_parser_log.20101004 | tail -1 | awk '{ print $2 }'`
if [ $VAR = "Waiting" ]
then
echo " Restarting the gprs parserd process"
kill -9 $VAR
else
echo "Processed picked the file ,not restrting "
exit 0;



error::-
Code:
+ LOG_PATH=/temp/circles/ABHI/LOGs
++ date +%Y%m%d
+ DATE=20101004
+ LOG_NAME=gprs_cdr_parser_log.20101004
++ grep del_gprs_cdrs_parserd
++ ps -eaf
++ grep -v grep
++ awk '{ print $2 }'
+ PID=13137
+ cd //temp/circles/ABHI/LOGs
++ tail -10 gprs_cdr_parser_log.20101004
++ tail -1
++ awk '{ print $2 }'
+ VAR=Waiting
gprs_cdr_parser_restart.sh: line 16: syntax error: unexpected end of file


Last edited by Scott; 10-04-2010 at 10:30 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

2. Shell Programming and Scripting

String matching

for a certain directory, I want to grep a particular file called ABCD so what I do is ls /my/dir | grep -i "ABCD" | awk '{print $9}' however, there is also this file called ABCDEFG, the above command would reurn both file when I only want ABCD, please help! (3 Replies)
Discussion started by: mpang_
3 Replies

3. Shell Programming and Scripting

matching a string

I have a requirement of shell script where i need to read the File name i.e ls -t | head -1 and Match that Filename with some delimited values which are in a separate File. For Example i am reading the File name i.e (ls -t | head -1) after that i need to read one more sequential file which... (2 Replies)
Discussion started by: dsdev_123
2 Replies

4. Shell Programming and Scripting

searching the required string and appending string to it.

Hi all, I have some data in the form of adc|nvhs|nahssn|njadnk|nkfds in the above data i need to write a script so thet it will append "|||" to the third occurnace in the string ..... the outout should look like adc|nvhs|nahssn||||njadnk|nkfds Thanks, Firestar. (6 Replies)
Discussion started by: firestar
6 Replies

5. Shell Programming and Scripting

Matching string from input to string of file

Hi, i want to know how to compare string of file with input string im trying following code: file_no=`paste -s -d "||||\n" a.txt | cut -c 1` #it will return collection number from file echo "enter number" read " curr_no" if ; then echo " current number already present" fi ... (4 Replies)
Discussion started by: a_smith
4 Replies

6. Shell Programming and Scripting

Find if XML element has a matching required element

I want to check if every <Part> element has corresponding <Description> in this sample XML. ....<Lot Of XML> <Inv lineNumber="2"> <Item> ... (4 Replies)
Discussion started by: kchinnam
4 Replies

7. Shell Programming and Scripting

Pattern Matching and extracting the required fields in Perl

Hi All, I am writing the following Perl Scrip and need your help in Pattern matching : I have the following Shell Script that would read line by line from the file (file_svn) and would inturn calls the Perl Script: #!/bin/bash perl_path="/home/dev/filter"... (2 Replies)
Discussion started by: filter
2 Replies

8. AIX

Grepping before and after lines for required string

Hi All, I am new to AIX unix . i need to grep for a pattern and if pattern is found then i need 3 before the pattern line found and 3 lines after the pattern found. (11 Replies)
Discussion started by: coolvibh
11 Replies

9. Shell Programming and Scripting

How to grep the required part from the string?

Hi All, I am trying to fetch the particular content from the result of grep command. I am using ps-ef |grep engine| awk '{print $6}' above statement giving me /opt/test/user/domain/CORPTEST/application/CacheScheduler/CacheScheduler-CacheScheduler but I want (13 Replies)
Discussion started by: sharsour
13 Replies

10. Shell Programming and Scripting

sed pattern matching help required

Hi I am trying to pattern match with sed, if it finds a match I need it to insert characters at the 28th position, its working but its also adding an extra space and I don't know why, below is the code. sed 's/715023044/\n&/g' $asn | sed '/^71502304413-000/s/./B4/28' | sed -e :a -e... (4 Replies)
Discussion started by: firefox2k2
4 Replies
ZGREP(1)                                                      General Commands Manual                                                     ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 01:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy