The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SED Search Pattern and Replace with the Pattern racbern Shell Programming and Scripting 4 03-15-2008 05:59 AM
Search for a pattern from the result of search boopathi_d Shell Programming and Scripting 3 12-05-2007 09:54 AM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 03:41 PM
List files that do not match the search pattern olapxpert UNIX for Dummies Questions & Answers 7 04-14-2005 03:49 PM
List files that do not match the search pattern olapxpert IP Networking 1 04-14-2005 02:37 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-13-2006
ynaik002 ynaik002 is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 1
search all files for a pattern

Hi there,
I am looking for a shell script which recursively searches all the files under all the directories for a pattern specified in the script. For e.g., i am looking forward to search for the file names which contains numbers of the form 001*****.

Thanks in advance,
Naik
  #2 (permalink)  
Old 02-13-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Try this bit of code:
Code:
find <dir_you_want_to_search> -type f -exec grep -l 001[0-9][0-9][0-9][0-9][0-9] {} \;
Not thinking too clearly though. Other guys probably will give you a better solution.
  #3 (permalink)  
Old 02-17-2006
groovemaven groovemaven is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 1
Quote:
Originally Posted by blowtorch
Try this bit of code:
Code:
find <dir_you_want_to_search> -type f -exec grep -l 001[0-9][0-9][0-9][0-9][0-9] {} \;
Not thinking too clearly though. Other guys probably will give you a better solution.
I'd probably do:

find <dir_you_want_search_> -type f -exec grep -lE '^001\d{5}$' {} \;

saves on some typing. =)
  #4 (permalink)  
Old 02-17-2006
shephardfamily shephardfamily is offline
Registered User
  
 

Join Date: Feb 2006
Location: Michigan
Posts: 5
Unhappy Unix desired output. (Help!!!!!)

Okay I like the diff command.

diff arlog arlog.NWS | tr -d '\t ' | awk -F \| ' { print $1$2 } ' >> NEWERRORS

Next:
I would like to add: NEW TIME STAMP AT: `date` in the new file. Where can I put this portion of text. Let me explain. Since I will be searching the NEWERRORS log and it will look something like:

<NoLBAHLingotitdirectory
<****Removingarmonfilein/export/home/fininter/load
</loader/findev/log/FriFeb1716:30:21EST2006
<****Creatingarmonfilein/export/home/fininter/load
<*********LOCKBOX-GETBANKFILEFROMendeavour
<lbhap_get_bank_fileY
<CheckforLBHAPfileinendeavourdirectory
<NoLBHAPingotitdirectory
<lbahl_get_bank_fileY
<CheckforLBAHLfileinendeavourdirectory
<NoLBAHLingotitdirectory
<****Removingarmonfilein/export/home/fininter/load
</loader/findev/log/FriFeb1716:32:21EST2006
<****Creatingarmonfilein/export/home/fininter/load
<*********LOCKBOX-GETBANKFILEFROMendeavour
<lbhap_get_bank_fileY
<CheckforLBHAPfileinendeavourdirectory
<NoLBHAPingotitdirectory
<lbahl_get_bank_fileY
<CheckforLBAHLfileinendeavourdirectory
<NoLBAHLingotitdirectory
<****Removingarmonfilein/export/home/fininter/load
---

>NEWTIMESTAMPAT:WedFeb1515:25:12EST2006

>/appl/finance/findev/ar/bin/arlog.NWS:NEWTIMESTAMPAT:WedFeb1515:25:12EST2006
>NEWTIMESTAMPAT:WedFeb1515:48:16EST2006

<data> 0403-031 The fork function failed. There is not enough memory available.
<data>
<data>ftp: connect: Connection timed out.
<data>
<data>
>NEWTIMESTAMPAT:WedFeb1519:04:07EST2006
<data>
<data>ORA-06508: PL/SQL: could not find program unit being called.
<data>
<data>
>NEWTIMESTAMPAT:WedFeb1520:05:38EST2006findev:/appl/finance/findev/ar/bin: F \| ' { print $1$2 } ' >> errors <
findev:/appl/finance/findev/ar/bin: vi errors
"errors" 548 lines, 19849 characters
"errors" 548 lines, 19849 characters
1,541c1,5


Of course it doesn't look like this as of yet but I would like it to get there.
  #5 (permalink)  
Old 02-23-2006
shephardfamily shephardfamily is offline
Registered User
  
 

Join Date: Feb 2006
Location: Michigan
Posts: 5
Get all lines from the arlog based on the last PREVIOUS_TIME date and time.

Quote:
Originally Posted by shephardfamily
Okay I like the diff command.

diff arlog arlog.NWS | tr -d '\t ' | awk -F \| ' { print $1$2 } ' >> NEWERRORS

Next:
I would like to add: NEW TIME STAMP AT: `date` in the new file. Where can I put this portion of text. Let me explain. Since I will be searching the NEWERRORS log and it will look something like:

<NoLBAHLingotitdirectory
<****Removingarmonfilein/export/home/fininter/load
</loader/findev/log/FriFeb1716:30:21EST2006
<****Creatingarmonfilein/export/home/fininter/load
<*********LOCKBOX-GETBANKFILEFROMendeavour
<lbhap_get_bank_fileY
<CheckforLBHAPfileinendeavourdirectory
<NoLBHAPingotitdirectory
<lbahl_get_bank_fileY
<CheckforLBAHLfileinendeavourdirectory
<NoLBAHLingotitdirectory
<****Removingarmonfilein/export/home/fininter/load
</loader/findev/log/FriFeb1716:32:21EST2006
<****Creatingarmonfilein/export/home/fininter/load
<*********LOCKBOX-GETBANKFILEFROMendeavour
<lbhap_get_bank_fileY
<CheckforLBHAPfileinendeavourdirectory
<NoLBHAPingotitdirectory
<lbahl_get_bank_fileY
<CheckforLBAHLfileinendeavourdirectory
<NoLBAHLingotitdirectory
<****Removingarmonfilein/export/home/fininter/load
---

>NEWTIMESTAMPAT:WedFeb1515:25:12EST2006

>/appl/finance/findev/ar/bin/arlog.NWS:NEWTIMESTAMPAT:WedFeb1515:25:12EST2006
>NEWTIMESTAMPAT:WedFeb1515:48:16EST2006

<data> 0403-031 The fork function failed. There is not enough memory available.
<data>
<data>ftp: connect: Connection timed out.
<data>
<data>
>NEWTIMESTAMPAT:WedFeb1519:04:07EST2006
<data>
<data>ORA-06508: PL/SQL: could not find program unit being called.
<data>
<data>
>NEWTIMESTAMPAT:WedFeb1520:05:38EST2006findev:/appl/finance/findev/ar/bin: F \| ' { print $1$2 } ' >> errors <
findev:/appl/finance/findev/ar/bin: vi errors
"errors" 548 lines, 19849 characters
"errors" 548 lines, 19849 characters
1,541c1,5


Of course it doesn't look like this as of yet but I would like it to get there.

I am trying to put this script together and I am having grave problems doing so, this is the structure:

#!/bin/sh
# Every 6 hours

# Get all lines from the arlog based on the last PREVIOUS_TIME date and time.

PREVIOUS_TIME='DATE AND TIME: `date`' in the arlog

NEW_TIME='TODAYS DATE AND TIME: `date` ' in the arlog

#LIST OF ERRORS THAT WILL BE SEARCHED.

ERRMSG='CHECKING FOR ERRORS IN ARLOG: ERROR 9999'
ERRMSG1='0403-031 The fork function failed. There is not enough memory available.'
ERRMSG2='Login failed.'
ERRMSG3='ftp: connect: Connection timed out.'
ERRMSG4='ftp: connect: Connection refused.'
ERRMSG5='endeavour: unknown host or invalid literal address.'
ERRMSG6='ftp: Unknown host diamprodf0'
ERRMSG7='ORA-06508: PL/SQL: could not find program unit being called.'
ERRMSG8='ORA-01034: ORACLE not available.'
ERRMSG9='ORA-27101: shared memory realm does not exist.'
ERRMSG10='ORA-01005: null password given; logon denied.'
ERRMSG11='SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL.'
ERRMSG12='ORA-04068: existing state of packages has been discarded.'
ERRMSG13='ORA-04063: package body "FININTER.HAP_CUSTOMERS_INTERFACE" has errors.'
ERRMSG14='ORA-06512: IN LINE ERROR.'
ERRMSG15='ORA-01005: null password given.'

grep 'DATE STAMP: $PREVIOUS_TIME ' arlog >> TEMP_ARLOG.log

if $NEW_TIME in the arlog NOT EQUAL $PREVIOUS_TIME in arlog
then
egrep "(${ERRMSG} | ${ERRMSG1} | ${ERRMSG2} |........) from arlog.
if NO ERRORS EXIST
then
put $NEW_TIME 'No Errors To Date and time" >> arlog
else
mailx -s '$ERRORS `date` to [FMT] with message describing error or errors.
grep 'LAST TIME TRANSMISSION:' $PREVIOUS_TIME >> arlog
fi
fi

Can anyone help me?
12green
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0