Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to grep with certain condition? Post 302808847 by ramsavi on Friday 17th of May 2013 03:52:08 PM
Old 05-17-2013
How to grep with certain condition?

hi all,
i have an xml what i have to do is to search for the source id(s1) and if it matches with that in xml then extract the file mask from the name of the file i.e if the file name is
idr_%YYYY%%MM%%DD%_%N%.idr then , i want the part after first %
and before last % ie in this case
%YYYY%%MM%%DD%_%N%


Code:
<?xml version="1.0" encoding="UTF-8"?>
<Sources>
  <DatabaseConnection>
    <TNSName>dgid1rr</TNSName>
    <Username>rte</Username>
    <Password>rted1</Password>
  </DatabaseConnection>
  <Logger>
    <LogFilePath>/export/home/dgid1rr/merge/log</LogFilePath>
    <LogFileName>idr_merge_log</LogFileName>
    <LogLevel>Info</LogLevel>
  </Logger>
  <Source id="S1">
    <FileMask>idr_%YYYY%%MM%%DD%_%N%.idr</FileMask>
    <TimeLag>100</TimeLag>
    <Backup>True</Backup>
    <InputFilePath>/export/home/dgid1rr/cdr1/input</InputFilePath>
    <OutputFilePath>/export/home/dgid1rr/merge/cdr1/output</OutputFilePath>
    <BackupFilePath>/export/home/dgid1rr/merge/cdr1/backup</BackupFilePath>
    <ProcessOrder>FileTimestamp</ProcessOrder>
    <Enable>True</Enable>
    <MaxFiles>3</MaxFiles>
    <MaxRecs>25</MaxRecs>
  </Source>
  <Source id="S2">
    <FileMask>idr_%2N%.idr</FileMask>
    <TimeLag>300</TimeLag>
    <Backup>True</Backup>
    <InputFilePath>/export/home/dgid1rr/merge/cdr2/input</InputFilePath>
    <OutputFilePath>/export/home/dgid1rr/merge/cdr2/output</OutputFilePath>
    <BackupFilePath>/export/home/dgid1rr/merge/cdr2/backup</BackupFilePath>
    <ProcessOrder>OSTimestamp</ProcessOrder>
    <Enable>True</Enable>
    <MaxFiles>2</MaxFiles>
  </Source>
</Sources>

Thanks

Last edited by Scott; 05-17-2013 at 04:58 PM.. Reason: Moved thread - Not a Redhat question
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep command with AND condition

I want to do a grep with AND condition. I have three files. file1.txt ======== UNIX ...... WINDOWS ........ ORACLE file2.txt ======== UNIX ....... WINDOWS ...and many such files in a directory (6 Replies)
Discussion started by: prasperl
6 Replies

2. Homework & Coursework Questions

Grep line above X condition

1. The problem statement, all variables and given/known data: I have to grep a data file called datebook.txt. The last information in each line is a salary. I have to grep all the lines which precede those lines with 6 figure salaries. I can't SID it, or use Perl. It has to be grep (or egrep or... (3 Replies)
Discussion started by: DrSammyD
3 Replies

3. Shell Programming and Scripting

grep inside if condition - need help

hi i need help with below code. if ] then log "Exiting the script as ID= NULL" log "Please run script first." fi i am calling grep inside this but its not running any ideas why ?? input file is like this -- Msg 102, Level 20, State 1: Server... (4 Replies)
Discussion started by: dazdseg
4 Replies

4. Shell Programming and Scripting

grep in the if condition

Hi, In this code can able to match the pattern without case sensitive. Is that possible? if u knw plz help me... code: echo "Enter name to search" read n if ; echo "name found" else echo "Not Found" fi (8 Replies)
Discussion started by: boopal
8 Replies

5. Shell Programming and Scripting

grep not equal to condition

I have below files under dir_a and dir_b and i want to sort out number of dir_a and dir_b files seperately and if i do the grep it should retrun 2 files in dir_a and 1 file in dir_b. /dir_a/12345678 /dir_a/87654321 /dir_a/dir_b/12345687 But i am getting cat file|grep dir_a|wc -l 3... (6 Replies)
Discussion started by: prash358
6 Replies

6. Shell Programming and Scripting

Where condition in grep or awk?

Dear All, I need help.. I am having a csv file. Home_TITLE,People_TITLE,Repo_ALIAS HMN5530,RKY5807,/mine_repo/rike001 HMN5530,SRY6443,/mine_repo/rike001 HMN5530,ARDY001,/mine_repo/rike001 If i have two value in varible RKY5807, HMN5530. how can fetch and store another value... (6 Replies)
Discussion started by: yadavricky
6 Replies

7. UNIX for Dummies Questions & Answers

Grep certain lines with condition

file input aaaa,52C aaaa,50C bbbb,50C bbbb,58C aaaa,52C bbbb,50C aaaa,30C bbbb,58C cccc,60C i want to print uniq lines with its max value of column2 expected output aaaa,52C bbbb,58C cccc,60C tks (4 Replies)
Discussion started by: radius
4 Replies

8. UNIX for Dummies Questions & Answers

Grep with condition

I have file input AAAA_XX_Start> rlong . 0W 130526-11:36:13 10.128.13.226 9.0j RBS_NODE_MODEL_N_1_50 stopfile=/tmp/13019 .. ================================================================================================================= MO ... (2 Replies)
Discussion started by: radius
2 Replies

9. UNIX for Dummies Questions & Answers

Combining grep patterns with OR condition?!

Hello! I have a question about how to combine patterns in grep commands with the OR operator. So I have this little assignment here: Provide a regular expression that matches email addresses for San Jose City College faculty. A San Jose City college faculty’s email address takes the form:... (1 Reply)
Discussion started by: kalpcalp
1 Replies
STAG-AUTOSCHEMA(1p)					User Contributed Perl Documentation				       STAG-AUTOSCHEMA(1p)

NAME
stag-autoschema - writes the implicit stag-schema for a stag file SYNOPSIS
stag-autoschema -w sxpr sample-data.xml stag-autoschema -dtd sample-data.xml DESCRIPTION
Takes a stag compatible file (xml, sxpr, itext), or a file in any format plus a parser, and writes out the implicit underlying stag-schema stag-schema should look relatively self-explanatory. Here is an example stag-schema, shown in sxpr syntax: (db (person* (name "s" (address+ (address_type "s") (street "s") (street2? "s") (city "s") (zip? "s"))))) The database db contains zero or more persons, each person has a mandatory name and at least one address. The cardinality mnemonics are as follows: + 1 or more ? 0 or one * 0 or more The default cardinality is 1 ARGUMENTS
-p|parser FORMAT FORMAT is one of xml, sxpr or itext, or the name of a perl module xml assumed as default -dtd exports schema as DTD -w|writer FORMAT FORMAT is one of xml, sxpr or itext, or the name of a perl module, OR DTD The default is sxpr note that stag schemas exported as xml will be invalid xml, due to the use of symbols *, +, ? in the node names LIMITATIONS
not event based - memory usage becomes exhorbitant on large files; prepare a small sample beforehand perl v5.10.0 2008-12-23 STAG-AUTOSCHEMA(1p)
All times are GMT -4. The time now is 01:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy