Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Extract common data out of multiple files Post 302750033 by mukulverma2408 on Sunday 30th of December 2012 03:52:31 PM
Old 12-30-2012
Hi sathyaonnuix,
Consider the below scenario :
Code:
cat filea
line1
line2
repeat1
line3
repeat2
line4
repeat1

Code:
cat fileb
1234567
repeat1
repeat2
bbbbbb

Code:
cat filec
line1
repeat1
repeat2
line2
repeat1
line3

Now executing the script for these three files would result in below output
Code:
repeat1
repeat2
repeat1

repetition of repeat1 which i think was not required

P.S. I am running while loop on filea
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to rename multiple files with a common suffix

Hi, There are multiple files like file1_11 file2_11 file3_11.....and so on. How to rename them such tht the suffix _11 is removed and they become file1, file2, file3. Any help is appreciated. Regards er_ashu (1 Reply)
Discussion started by: er_ashu
1 Replies

2. Shell Programming and Scripting

Get common lines from multiple files

FileA chr1 31237964 NP_001018494.1 PUM1 M340L chr1 31237964 NP_055491.1 PUM1 M340L chr1 33251518 NP_037543.1 AK2 H191D chr1 33251518 NP_001616.1 AK2 H191D chr1 57027345 NP_001004303.2 C1orf168 P270S FileB chr1 ... (9 Replies)
Discussion started by: genehunter
9 Replies

3. UNIX for Dummies Questions & Answers

AWK, extract data from multiple files

Hi, I'm using AWK to try to extract data from multiple files (*.txt). The script should look for a flag that occurs at a specific position in each file and it should return the data to the right of that flag. I should end up with one line for each file, each containing 3 columns:... (8 Replies)
Discussion started by: Liverpaul09
8 Replies

4. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

5. Shell Programming and Scripting

Extract common words from two/more csv files

I have two (or more, to make it generic) csv files. Each line contains words separated by comma. None of words have any space. The number of words per line is not fixed. Some may have one, and some may have 12... The number of lines per file is also not fixed. What I need is to find common words... (1 Reply)
Discussion started by: nick2011
1 Replies

6. Shell Programming and Scripting

Find common lines between multiple files

Hello everyone A few years Ago the user radoulov posted a fancy solution for a problem, which was about finding common lines (gene variation names) between multiple samples (files). The code was: awk 'END { for (R in rec) { n = split(rec, t, "/") if (n > 1) dup = dup ?... (5 Replies)
Discussion started by: bibb
5 Replies

7. Shell Programming and Scripting

Compare multiple files, and extract items that are common to ALL files only

I have this code awk 'NR==FNR{a=$1;next} a' file1 file2 which does what I need it to do, but for only two files. I want to make it so that I can have multiple files (for example 30) and the code will return only the items that are in every single one of those files and ignore the ones... (7 Replies)
Discussion started by: castrojc
7 Replies

8. Shell Programming and Scripting

Extract data in tabular format from multiple files

Hi, I have directory with multiple files from which i need to extract portion of specif lines and insert it in a new file, the new file will contain a separate columns for each file data. Example: I need to extract Value_1 & Value_3 from all files and insert in output file as below: ... (2 Replies)
Discussion started by: belalr
2 Replies

9. Shell Programming and Scripting

Get both common and missing values from multiple files

Hi, I have 5 files with two columns. I need to merge all the 5 files based on column 1. If any of them are missing then corresponding 2nd column should be substituted by missing value. I know hoe to do this for 2 files. but how can I implement for 5 files. I tried this based on 5 files but it... (2 Replies)
Discussion started by: Diya123
2 Replies

10. Shell Programming and Scripting

Merge multiple files with common header

Hi all, Say i have multiple files x1 x2 x3 x4, all with common header (date, time, year, age),, How can I merge them to one singe file "X" in shell scripting Thanks for your suggestions. (2 Replies)
Discussion started by: msarguru
2 Replies
pt::pe(3tcl)							   Parser Tools 						      pt::pe(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
pt::pe - Parsing Expression Serialization SYNOPSIS
package require Tcl 8.5 package require pt::pe ?1? package require char ::pt::pe verify serial ?canonvar? ::pt::pe verify-as-canonical serial ::pt::pe canonicalize serial ::pt::pe print serial ::pt::pe bottomup cmdprefix pe cmdprefix pe op arguments ::pt::pe topdown cmdprefix pe ::pt::pe equal seriala serialb ::pt::pe epsilon ::pt::pe dot ::pt::pe alnum ::pt::pe alpha ::pt::pe ascii ::pt::pe control ::pt::pe digit ::pt::pe graph ::pt::pe lower ::pt::pe print ::pt::pe punct ::pt::pe space ::pt::pe upper ::pt::pe wordchar ::pt::pe xdigit ::pt::pe ddigit ::pt::pe terminal t ::pt::pe range ta tb ::pt::pe nonterminal nt ::pt::pe choice pe... ::pt::pe sequence pe... ::pt::pe repeat0 pe ::pt::pe repeat1 pe ::pt::pe optional pe ::pt::pe ahead pe ::pt::pe notahead pe _________________________________________________________________ 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 provides commands to work with the serializations of parsing expressions as managed by the Parser Tools, and specified in sec- tion PE serialization format. This is a supporting package in the Core Layer of Parser Tools. IMAGE: arch_core_support API
::pt::pe verify serial ?canonvar? This command verifies that the content of serial is a valid serialization of a parsing expression and will throw an error if that is not the case. The result of the command is the empty string. If the argument canonvar is specified it is interpreted as the name of a variable in the calling context. This variable will be written to if and only if serial is a valid regular serialization. Its value will be a boolean, with True indicating that the seri- alization is not only valid, but also canonical. False will be written for a valid, but non-canonical serialization. For the specification of serializations see the section PE serialization format. ::pt::pe verify-as-canonical serial This command verifies that the content of serial is a valid canonical serialization of a parsing expression and will throw an error if that is not the case. The result of the command is the empty string. For the specification of canonical serializations see the section PE serialization format. ::pt::pe canonicalize serial This command assumes that the content of serial is a valid regular serialization of a parsing expression and will throw an error if that is not the case. It will then convert the input into the canonical serialization of this parsing expression and return it as its result. If the input is already canonical it will be returned unchanged. For the specification of regular and canonical serializations see the section PE serialization format. ::pt::pe print serial This command assumes that the argument serial contains a valid serialization of a parsing expression and returns a string containing that PE in a human readable form. The exact format of this form is not specified and cannot be relied on for parsing or other machine-based activities. For the specification of serializations see the section PE serialization format. ::pt::pe bottomup cmdprefix pe This command walks the parsing expression pe from the bottom up to the root, invoking the command prefix cmdprefix for each partial expression. This implies that the children of a parsing expression PE are handled before PE. The command prefix has the signature cmdprefix pe op arguments I.e. it is invoked with the parsing expression pe the walk is currently at, the op'erator in the pe, and the operator's argu- ments. The result returned by the command prefix replaces pe in the parsing expression it was a child of, allowing transformations of the expression tree. This also means that for all inner parsing expressions the contents of arguments are the results of the command prefix invoked for the children of this inner parsing expression. ::pt::pe topdown cmdprefix pe This command walks the parsing expression pe from the root down to the leaves, invoking the command prefix cmdprefix for each par- tial expression. This implies that the children of a parsing expression PE are handled after PE. The command prefix has the same signature as for bottomup, see above. The result returned by the command prefix is ignored. ::pt::pe equal seriala serialb This command tests the two parsing expressions seriala and serialb for structural equality. The result of the command is a boolean value. It will be set to true if the expressions are identical, and false otherwise. String equality is usable only if we can assume that the two parsing expressions are pure Tcl lists. ::pt::pe epsilon This command constructs the atomic parsing expression for epsilon. ::pt::pe dot This command constructs the atomic parsing expression for dot. ::pt::pe alnum This command constructs the atomic parsing expression for alnum. ::pt::pe alpha This command constructs the atomic parsing expression for alpha. ::pt::pe ascii This command constructs the atomic parsing expression for ascii. ::pt::pe control This command constructs the atomic parsing expression for control. ::pt::pe digit This command constructs the atomic parsing expression for digit. ::pt::pe graph This command constructs the atomic parsing expression for graph. ::pt::pe lower This command constructs the atomic parsing expression for lower. ::pt::pe print This command constructs the atomic parsing expression for print. ::pt::pe punct This command constructs the atomic parsing expression for punct. ::pt::pe space This command constructs the atomic parsing expression for space. ::pt::pe upper This command constructs the atomic parsing expression for upper. ::pt::pe wordchar This command constructs the atomic parsing expression for wordchar. ::pt::pe xdigit This command constructs the atomic parsing expression for xdigit. ::pt::pe ddigit This command constructs the atomic parsing expression for ddigit. ::pt::pe terminal t This command constructs the atomic parsing expression for the terminal symbol t. ::pt::pe range ta tb This command constructs the atomic parsing expression for the range of terminal symbols ta ... tb. ::pt::pe nonterminal nt This command constructs the atomic parsing expression for the nonterminal symbol nt. ::pt::pe choice pe... This command constructs the parsing expression representing the ordered or prioritized choice between the argument parsing expres- sions. The first argument has the highest priority. ::pt::pe sequence pe... This command constructs the parsing expression representing the sequence of the argument parsing expression. The first argument is the first element of the sequence. ::pt::pe repeat0 pe This command constructs the parsing expression representing the zero or more repetition of the argument parsing expression pe, also known as the kleene closure. ::pt::pe repeat1 pe This command constructs the parsing expression representing the one or more repetition of the argument parsing expression pe, also known as the positive kleene closure. ::pt::pe optional pe This command constructs the parsing expression representing the optionality of the argument parsing expression pe. ::pt::pe ahead pe This command constructs the parsing expression representing the positive lookahead of the argument parsing expression pe. ::pt::pe notahead pe This command constructs the parsing expression representing the negative lookahead of the argument parsing expression pe. 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 <- Term (AddOp Term)* then its canonical serialization (except for whitespace) is {x {n Term} {* {x {n AddOp} {n Term}}}} 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, LL(k), PEG, TDPL, context-free languages, expression, grammar, matching, parser, parsing expression, parsing expression grammar, push down automaton, recursive descent, state, top-down parsing languages, transducer CATEGORY
Parsing and Grammars COPYRIGHT
Copyright (c) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net> pt 1 pt::pe(3tcl)
All times are GMT -4. The time now is 05:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy