Sponsored Content
Top Forums Shell Programming and Scripting Sleep till grep find the string Post 302976746 by elbrand on Tuesday 5th of July 2016 11:39:52 AM
Old 07-05-2016
you could simply wait, till files with the name pattern occur. It could be useful to add a timeout to avoid your script to wait forever...

Code:
#! /usr/bin/bash
 cd /IN/service_packages/SMS/cdr/received
 MYDATE=`date +"%Y%m%d%H%M"`

while ! { find . -mindepth 1 -maxdepth 1 -name "cubic-live-slc-a_ACS_${MYDATE}*" | grep . ; } ; do sleep 10 ; done
  
 #get the value then divide by 60
#DAPS_SLC01
data=`grep "CALL TYPE=D" cubic-live-slc-a_ACS_$MYDATE* | wc -l`
echo Data:
r=`echo "scale=3; $data/60" | bc | sed -e 's/^\./0./;s/[0]*$//g'`
echo DAPS_SLC-a $r
 #DAPS_SLC02
data1=`grep "CALL TYPE=D" cubic-live-slc-b_ACS_$MYDATE* | wc -l`
r=`echo "scale=3; $data1/60" | bc | sed -e 's/^\./0./;s/[0]*$//g'`
echo DAPS_SLC-b $r
 #DAPS Total
r=`echo "scale=3; ($data + $data1)/60" | bc | sed -e 's/^\./0./;s/[0]*$//g'`
echo DAPS_Total $r

This User Gave Thanks to elbrand For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace all string instances found by find+grep

Hello all Im performing find + grep operation that looks like this : find . -name "*.dsp" | xargs grep -on Project.lib | grep -v ':0' and I like to add to this one liner the possibility to replace the string " Project.lib" that found ( more then once in file ) with "Example.lib" how can I do... (0 Replies)
Discussion started by: umen
0 Replies

2. Shell Programming and Scripting

grep string and find line before

hi, i have to grep for string in file but i want to find the group of this line so i must get lines before and select the group. the file look like : ####name_groupe1 alphanumeric line alphanumeric line .. ####name_groupe2 alphanumeric line alphanumeric line .. ####name_groupe3... (4 Replies)
Discussion started by: kamel.seg
4 Replies

3. UNIX for Dummies Questions & Answers

Loop till you find a string in a fine <-- Need Help New to Unix Scripting

Guys - I am new to Unix scripting and am in need for a script that does the following. I have bits and pieces created and tested but i am just having a little difficult time getting it all together. - Loop through till it finds a string in a specific file. Any help is greatly appreciated. ... (1 Reply)
Discussion started by: mrehman
1 Replies

4. Shell Programming and Scripting

find exarct string using grep

Hi i have t1 file like: HiPerformance: Recalculation Dates|234| HiPerformance: Recalculation|456| ..... ..... .... ... i wrote grep command like: grep "HiPerformance: Recalculation" t1 out put: HiPerformance: Recalculation Dates|234| HiPerformance: Recalculation|456| But i... (3 Replies)
Discussion started by: koti_rama
3 Replies

5. UNIX for Dummies Questions & Answers

grep string and then find another string

I have a file that looks like this: Name=TOM abcded asdfas fkoiaerj inadhah Name=Chris 23nafds vasdkfna afadns afdadsfa aaaaaa bbbbbb cccccc I would to search for the string 'bbbbbb', then I would like to search above that string for the 1st occurrence of "Name" and not the other... (7 Replies)
Discussion started by: doza22
7 Replies

6. Shell Programming and Scripting

extract till occurance of a string

hi , i have an xml that comes in a single, the entire xml file is read as a single line when i open in edit plus or unix. i need to amend the contents of this xml file. below is the extract from the file <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"... (5 Replies)
Discussion started by: sais
5 Replies

7. UNIX for Dummies Questions & Answers

Using grep to find files that don't contain a string

Hi all, I am still learning my way around unix commands and I have the following question. I have a website and I want to search for all the html pages that don't contain a certain js file. The file I am searching for is located under /topfolder/js/rules.js . So I assume in my grep search I... (5 Replies)
Discussion started by: SyphaX
5 Replies

8. Shell Programming and Scripting

Grep with loop till search is done

I need help to put a script where it runs the svn command grep'ing for the ticket# in the comments to see if the ticket was used in the latest commit. so on command line: ./test.sh ticket-1 ticket-2 ticket-3 It should be able to check if ticket-1 is used first and if not then check if... (2 Replies)
Discussion started by: iaav
2 Replies

9. Shell Programming and Scripting

Grep command to find string in Variable in file2

Hi , I am executing 2 queries and output is saved in file1.txt and file2.txt example of file1.txt Testing word Doc.docx,/Lab/Development and Validation/Multitest/MT_010708/Testing,Development and Validation,root,11-Mar-2014,,,,, Testing Excel _.xlsx,/Lab/Development and... (3 Replies)
Discussion started by: Sunil Mathapati
3 Replies

10. Shell Programming and Scripting

Grep to find an exact string

Hi all, I tried searching the forum for this, and I read numerous suggestions here and even on other forums, and I cannot get this to want the way that I need it to. I tried grep -W / -f to no luck. Here is what I have. I have a list of file names- FILE1-FILE1TEST,FILE1RELATION... (7 Replies)
Discussion started by: jeffs42885
7 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 11:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy