![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SED Search Pattern and Replace with the Pattern | racbern | Shell Programming and Scripting | 4 | 03-15-2008 02:59 AM |
| Search for a pattern from the result of search | boopathi_d | Shell Programming and Scripting | 3 | 12-05-2007 06:54 AM |
| Search file for pattern and grab some lines before pattern | frustrated1 | Shell Programming and Scripting | 2 | 12-22-2005 12:41 PM |
| List files that do not match the search pattern | olapxpert | UNIX for Dummies Questions & Answers | 7 | 04-14-2005 12:49 PM |
| List files that do not match the search pattern | olapxpert | IP Networking | 1 | 04-14-2005 11:37 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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] {} \;
|
|
#3
|
|||
|
|||
|
Quote:
find <dir_you_want_search_> -type f -exec grep -lE '^001\d{5}$' {} \; saves on some typing. =) |
|
#4
|
|||
|
|||
|
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
|
|||
|
|||
|
Get all lines from the arlog based on the last PREVIOUS_TIME date and time.
Quote:
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? |
|||
| Google The UNIX and Linux Forums |