Sponsored Content
Top Forums Shell Programming and Scripting Finding 4 current files having specific File Name pattern Post 302725549 by lancesunny on Friday 2nd of November 2012 10:29:17 AM
Old 11-02-2012
Finding 4 different file name inside one folder meeting specific File Name pattern

Hi All,
I am trying to find 4 latest files inside one folder having following File Name pattern and store them into 4 different variables and then use for processing in my shell script. File name is fixed length.
1) Each file starts with = ABCJmdmfbsjop letters + 7 Digit Number _mm-dd-yyyy-hh-mm-ss-3 Digit Number.data
where ABCJmdmfbsjop :- is alphabet. Each file starts with this ABCJmdmfbsjop alphabet.
7 Digit Number :- Numeric 7 digits.
__:- Underscore character
mm-dd-yyyy-hh-mm-ss :- This will be today's month-date-Year-Hour-Minutes-seconds
-
3 digit number This cauld be any number.
.data:- this will be extension of the file.

For example:- ABCJmdmfbsjop0001552_11-02-2012-13-01-10-962.data

Any help regarding this will be appreciated.
Thanks,
-Lance

Last edited by lancesunny; 11-02-2012 at 01:07 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding a specific pattern from thousands of files ????

Hi All, I want to find a specific pattern from approximately 400000 files on solaris platform. Its very heavy for me to grep that pattern to each file individually. Can anybody suggest me some way to search for specific pattern (alpha numeric) from these forty thousand files. Please note that... (6 Replies)
Discussion started by: aarora_98
6 Replies

2. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

3. Shell Programming and Scripting

finding 0 byte files in current directory only

Hi Gurus, I have a directory A, which has some 0 byte files in it. This directory also has a subdirectory B which also has some 0 byte files in it. The problem: I only need to find out the names of the 0 byte files in the directory A. I'm using the following command find . -name *.zip... (6 Replies)
Discussion started by: ramky79
6 Replies

4. Shell Programming and Scripting

Finding files older than the current date and time and renaming and moving

Hi, I have a very urgent requirement here. I have to find all files in the specified directory but not in the sub directories(The directory name is stored in a variable) which are older than the current date as well as current time and rename it as filename_yyyymmddhhmmss.ext and move it into a... (7 Replies)
Discussion started by: ragavhere
7 Replies

5. Shell Programming and Scripting

Finding files in current directory when 100,000's files in current directory

Hi All I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age. I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
Discussion started by: kewong007
2 Replies

6. Red Hat

Moving of file content to another two files after searching with specific pattern

Hello, Please help me with this!! Thanks in advance!! I have a file named file.gc with the content: 1-- Mon Sep 10 08:53:09 CDT 2012 2revoke connect from FR2261; 3delete from mkt_allow where grantee = 'FR2261'; 4grant connect to FR2261 with '******'; 5alter user FR2261 comment... (0 Replies)
Discussion started by: raosr020
0 Replies

7. Shell Programming and Scripting

Finding duplicates in a file excluding specific pattern

I have unix file like below >newuser newuser <hello hello newone I want to find the unique values in the file(excluding <,>),so that the out put should be >newuser <hello newone can any body tell me what is command to get this new file. (7 Replies)
Discussion started by: shiva2985
7 Replies

8. Shell Programming and Scripting

How to find a file with a specific pattern for current sysdate & upon find email the details?

I need assistance with following requirement, I am new to Unix. I want to do the following task but stuck with file creation date(sysdate) Following is the requirement I need to create a script that will read the abc/xyz/klm folder and look for *.err files for that day’s date and then send an... (4 Replies)
Discussion started by: PreetArul
4 Replies

9. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies
pt::peg::from::json(n)						   Parser Tools 					    pt::peg::from::json(n)

__________________________________________________________________________________________________________________________________________________

NAME
pt::peg::from::json - PEG Conversion. Read JSON format SYNOPSIS
package require Tcl 8.5 package require pt::peg::from::json ?1? package require pt::peg package require json pt::peg::from::json convert text _________________________________________________________________ DESCRIPTION
Are you lost ? Do you have trouble understanding this document ? In that case please read the overview provided by the Introduction to Parser Tools. This document is the entrypoint to the whole system the current package is a part of. This package implements the converter from JSON markup to parsing expression grammars. It resides in the Import section of the Core Layer of Parser Tools, and can be used either directly with the other packages of this layer, or indirectly through the import manager provided by pt::peg::import. The latter is intented for use in untrusted environments and done through the corresponding import plugin pt::peg::import::json sitting between converter and import manager. IMAGE: arch_core_iplugins API
The API provided by this package satisfies the specification of the Converter API found in the Parser Tools Import API specification. pt::peg::from::json convert text This command takes the JSON markup encoding a parsing expression grammar and contained in text, and generates the canonical serial- ization of said grammar, as specified in section PEG serialization format. The created value is then returned as the result of the command. JSON GRAMMAR EXCHANGE FORMAT
The json format for parsing expression grammars was written as a data exchange format not bound to Tcl. It was defined to allow the exchange of grammars with PackRat/PEG based parser generators for other languages. It is formally specified by the rules below: [1] The JSON of any PEG is a JSON object. [2] This object holds a single key, pt::grammar::peg, and its value. This value holds the contents of the grammar. [3] The contents of the grammar are a JSON object holding the set of nonterminal symbols and the starting expression. The relevant keys and their values are rules The value is a JSON object whose keys are the names of the nonterminal symbols known to the grammar. [1] Each nonterminal symbol may occur only once. [2] The empty string is not a legal nonterminal symbol. [3] The value for each symbol is a JSON object itself. The relevant keys and their values in this dictionary are is The value is a JSON string holding the Tcl serialization of the parsing expression describing the symbols sen- tennial structure, as specified in the section PE serialization format. mode The value is a JSON holding holding one of three values specifying how a parser should handle the semantic value produced by the symbol. value The semantic value of the nonterminal symbol is an abstract syntax tree consisting of a single node node for the nonterminal itself, which has the ASTs of the symbol's right hand side as its children. leaf The semantic value of the nonterminal symbol is an abstract syntax tree consisting of a single node node for the nonterminal, without any children. Any ASTs generated by the symbol's right hand side are dis- carded. void The nonterminal has no semantic value. Any ASTs generated by the symbol's right hand side are discarded (as well). start The value is a JSON string holding the Tcl serialization of the start parsing expression of the grammar, as specified in the section PE serialization format. [4] The terminal symbols of the grammar are specified implicitly as the set of all terminal symbols used in the start expression and on the RHS of the grammar rules. As an aside to the advanced reader, this is pretty much the same as the Tcl serialization of PE grammars, as specified in section PEG seri- alization format, except that the Tcl dictionaries and lists of that format are mapped to JSON objects and arrays. Only the parsing expres- sions themselves are not translated further, but kept as JSON strings containing a nested Tcl list, and there is no concept of canonicity for the JSON either. EXAMPLE Assuming the following PEG for simple mathematical expressions PEG calculator (Expression) Digit <- '0'/'1'/'2'/'3'/'4'/'5'/'6'/'7'/'8'/'9' ; Sign <- '-' / '+' ; Number <- Sign? Digit+ ; Expression <- '(' Expression ')' / (Factor (MulOp Factor)*) ; MulOp <- '*' / '/' ; Factor <- Term (AddOp Term)* ; AddOp <- '+'/'-' ; Term <- Number ; END; a JSON serialization for it is { "pt::grammar::peg" : { "rules" : { "AddOp" : { "is" : "/ {t -} {t +}", "mode" : "value" }, "Digit" : { "is" : "/ {t 0} {t 1} {t 2} {t 3} {t 4} {t 5} {t 6} {t 7} {t 8} {t 9}", "mode" : "value" }, "Expression" : { "is" : "/ {x {t (} {n Expression} {t )}} {x {n Factor} {* {x {n MulOp} {n Factor}}}}", "mode" : "value" }, "Factor" : { "is" : "x {n Term} {* {x {n AddOp} {n Term}}}", "mode" : "value" }, "MulOp" : { "is" : "/ {t *} {t /}", "mode" : "value" }, "Number" : { "is" : "x {? {n Sign}} {+ {n Digit}}", "mode" : "value" }, "Sign" : { "is" : "/ {t -} {t +}", "mode" : "value" }, "Term" : { "is" : "n Number", "mode" : "value" } }, "start" : "n Expression" } } and a Tcl serialization of the same is pt::grammar::peg { rules { AddOp {is {/ {t -} {t +}} mode value} Digit {is {/ {t 0} {t 1} {t 2} {t 3} {t 4} {t 5} {t 6} {t 7} {t 8} {t 9}} mode value} Expression {is {/ {x {t (} {n Expression} {t )}} {x {n Factor} {* {x {n MulOp} {n Factor}}}}} mode value} Factor {is {x {n Term} {* {x {n AddOp} {n Term}}}} mode value} MulOp {is {/ {t *} {t /}} mode value} Number {is {x {? {n Sign}} {+ {n Digit}}} mode value} Sign {is {/ {t -} {t +}} mode value} Term {is {n Number} mode value} } start {n Expression} } The similarity of the latter to the JSON should be quite obvious. PEG SERIALIZATION FORMAT
Here we specify the format used by the Parser Tools to serialize Parsing Expression Grammars as immutable values for transport, comparison, etc. We distinguish between regular and canonical serializations. While a PEG may have more than one regular serialization only exactly one of them will be canonical. regular serialization [1] The serialization of any PEG is a nested Tcl dictionary. [2] This dictionary holds a single key, pt::grammar::peg, and its value. This value holds the contents of the grammar. [3] The contents of the grammar are a Tcl dictionary holding the set of nonterminal symbols and the starting expression. The rel- evant keys and their values are rules The value is a Tcl dictionary whose keys are the names of the nonterminal symbols known to the grammar. [1] Each nonterminal symbol may occur only once. [2] The empty string is not a legal nonterminal symbol. [3] The value for each symbol is a Tcl dictionary itself. The relevant keys and their values in this dictionary are is The value is the serialization of the parsing expression describing the symbols sentennial structure, as specified in the section PE serialization format. mode The value can be one of three values specifying how a parser should handle the semantic value produced by the symbol. value The semantic value of the nonterminal symbol is an abstract syntax tree consisting of a single node node for the nonterminal itself, which has the ASTs of the symbol's right hand side as its children. leaf The semantic value of the nonterminal symbol is an abstract syntax tree consisting of a single node node for the nonterminal, without any children. Any ASTs generated by the symbol's right hand side are discarded. void The nonterminal has no semantic value. Any ASTs generated by the symbol's right hand side are discarded (as well). start The value is the serialization of the start parsing expression of the grammar, as specified in the section PE serial- ization format. [4] The terminal symbols of the grammar are specified implicitly as the set of all terminal symbols used in the start expression and on the RHS of the grammar rules. canonical serialization The canonical serialization of a grammar has the format as specified in the previous item, and then additionally satisfies the con- straints below, which make it unique among all the possible serializations of this grammar. [1] The keys found in all the nested Tcl dictionaries are sorted in ascending dictionary order, as generated by Tcl's builtin command lsort -increasing -dict. [2] The string representation of the value is the canonical representation of a Tcl dictionary. I.e. it does not contain super- fluous whitespace. EXAMPLE Assuming the following PEG for simple mathematical expressions PEG calculator (Expression) Digit <- '0'/'1'/'2'/'3'/'4'/'5'/'6'/'7'/'8'/'9' ; Sign <- '-' / '+' ; Number <- Sign? Digit+ ; Expression <- '(' Expression ')' / (Factor (MulOp Factor)*) ; MulOp <- '*' / '/' ; Factor <- Term (AddOp Term)* ; AddOp <- '+'/'-' ; Term <- Number ; END; then its canonical serialization (except for whitespace) is pt::grammar::peg { rules { AddOp {is {/ {t -} {t +}} mode value} Digit {is {/ {t 0} {t 1} {t 2} {t 3} {t 4} {t 5} {t 6} {t 7} {t 8} {t 9}} mode value} Expression {is {/ {x {t (} {n Expression} {t )}} {x {n Factor} {* {x {n MulOp} {n Factor}}}}} mode value} Factor {is {x {n Term} {* {x {n AddOp} {n Term}}}} mode value} MulOp {is {/ {t *} {t /}} mode value} Number {is {x {? {n Sign}} {+ {n Digit}}} mode value} Sign {is {/ {t -} {t +}} mode value} Term {is {n Number} mode value} } start {n Expression} } PE SERIALIZATION FORMAT
Here we specify the format used by the Parser Tools to serialize Parsing Expressions as immutable values for transport, comparison, etc. We distinguish between regular and canonical serializations. While a parsing expression may have more than one regular serialization only exactly one of them will be canonical. Regular serialization Atomic Parsing Expressions [1] The string epsilon is an atomic parsing expression. It matches the empty string. [2] The string dot is an atomic parsing expression. It matches any character. [3] The string alnum is an atomic parsing expression. It matches any Unicode alphabet or digit character. This is a custom extension of PEs based on Tcl's builtin command string is. [4] The string alpha is an atomic parsing expression. It matches any Unicode alphabet character. This is a custom exten- sion of PEs based on Tcl's builtin command string is. [5] The string ascii is an atomic parsing expression. It matches any Unicode character below U0080. This is a custom extension of PEs based on Tcl's builtin command string is. [6] The string control is an atomic parsing expression. It matches any Unicode control character. This is a custom exten- sion of PEs based on Tcl's builtin command string is. [7] The string digit is an atomic parsing expression. It matches any Unicode digit character. Note that this includes characters outside of the [0..9] range. This is a custom extension of PEs based on Tcl's builtin command string is. [8] The string graph is an atomic parsing expression. It matches any Unicode printing character, except for space. This is a custom extension of PEs based on Tcl's builtin command string is. [9] The string lower is an atomic parsing expression. It matches any Unicode lower-case alphabet character. This is a cus- tom extension of PEs based on Tcl's builtin command string is. [10] The string print is an atomic parsing expression. It matches any Unicode printing character, including space. This is a custom extension of PEs based on Tcl's builtin command string is. [11] The string punct is an atomic parsing expression. It matches any Unicode punctuation character. This is a custom extension of PEs based on Tcl's builtin command string is. [12] The string space is an atomic parsing expression. It matches any Unicode space character. This is a custom extension of PEs based on Tcl's builtin command string is. [13] The string upper is an atomic parsing expression. It matches any Unicode upper-case alphabet character. This is a cus- tom extension of PEs based on Tcl's builtin command string is. [14] The string wordchar is an atomic parsing expression. It matches any Unicode word character. This is any alphanumeric character (see alnum), and any connector punctuation characters (e.g. underscore). This is a custom extension of PEs based on Tcl's builtin command string is. [15] The string xdigit is an atomic parsing expression. It matches any hexadecimal digit character. This is a custom exten- sion of PEs based on Tcl's builtin command string is. [16] The string ddigit is an atomic parsing expression. It matches any decimal digit character. This is a custom extension of PEs based on Tcl's builtin command regexp. [17] The expression [list t x] is an atomic parsing expression. It matches the terminal string x. [18] The expression [list n A] is an atomic parsing expression. It matches the nonterminal A. Combined Parsing Expressions [1] For parsing expressions e1, e2, ... the result of [list / e1 e2 ... ] is a parsing expression as well. This is the ordered choice, aka prioritized choice. [2] For parsing expressions e1, e2, ... the result of [list x e1 e2 ... ] is a parsing expression as well. This is the sequence. [3] For a parsing expression e the result of [list * e] is a parsing expression as well. This is the kleene closure, describing zero or more repetitions. [4] For a parsing expression e the result of [list + e] is a parsing expression as well. This is the positive kleene clo- sure, describing one or more repetitions. [5] For a parsing expression e the result of [list & e] is a parsing expression as well. This is the and lookahead predi- cate. [6] For a parsing expression e the result of [list ! e] is a parsing expression as well. This is the not lookahead predi- cate. [7] For a parsing expression e the result of [list ? e] is a parsing expression as well. This is the optional input. Canonical serialization The canonical serialization of a parsing expression has the format as specified in the previous item, and then additionally satis- fies the constraints below, which make it unique among all the possible serializations of this parsing expression. [1] The string representation of the value is the canonical representation of a pure Tcl list. I.e. it does not contain superflu- ous whitespace. [2] Terminals are not encoded as ranges (where start and end of the range are identical). EXAMPLE Assuming the parsing expression shown on the right-hand side of the rule Expression <- '(' Expression ')' / Factor (MulOp Factor)* then its canonical serialization (except for whitespace) is {/ {x {t (} {n Expression} {t )}} {x {n Factor} {* {x {n MulOp} {n Factor}}}}} BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category pt of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
EBNF, JSON, LL(k), PEG, TDPL, context-free languages, conversion, expression, format conversion, grammar, matching, parser, parsing expres- sion, parsing expression grammar, push down automaton, recursive descent, serialization, state, top-down parsing languages, transducer CATEGORY
Parsing and Grammars COPYRIGHT
Copyright (c) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net> pt 1 pt::peg::from::json(n)
All times are GMT -4. The time now is 07:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy