Sponsored Content
Full Discussion: Pattern Match FileNames
Top Forums UNIX for Beginners Questions & Answers Pattern Match FileNames Post 303015990 by techedipro on Wednesday 18th of April 2018 12:51:29 AM
Old 04-18-2018
Pattern Match FileNames

I am on AIX.

I need to list the contents of the directory based on a pattern and write an XML output file with file names.

If a filename does NOT match the below pattern then write an OUTPUT xml file in the below xml format

Pattern


Code:
Starts with (.abc) and contains (def)
Starts with (.abc) and contains (pqr)
Ends with (.xml) & conatins (xyz)
Starts with (.tvs)
Contains(.hij)

Additionally irrespective of the patter match if the FileName Contains (space character) include that FileName in the Output XML file

Output File Structure

Code:
<Files>
<FiileName>LMN.txt</FileName>
<FileName>OTS.txt</FileName>
</Files>

Please advise

Last edited by RudiC; 04-18-2018 at 04:45 AM..
This User Gave Thanks to techedipro For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match first pattern first then extract second pattern match

My input file: <accession>Q91G55</accession> <name>043L_IIV6</name> <protein> <recommendedName> <location> <position position="294"/> </location> <fullName>Uncharacterized protein 043L</fullName> <accession>P18556</accession> <name>1106L_ASFB7</name> <protein> <recommendedName>... (5 Replies)
Discussion started by: patrick87
5 Replies

2. Shell Programming and Scripting

parse apl-numeric codes from filenames, and match them to entries in database

Hello, I am new to Unix scripting, and would like some help with my issue: I have vairous files having some alphanumeric codes in them e.g. 10000-01 34440TE 34590SR All these codes are stored in the database, and I need to parse these codes out of these filenames, and match them... (2 Replies)
Discussion started by: mvaidya
2 Replies

3. Shell Programming and Scripting

BASH find filenames in list that match certain "pattern."

I guess by "pattern," I mean something different from how that word is defined in the Linux world. If you take $ to mean a letter (a-z) and # to mean a number (0-9), then the pattern I'm trying to match is as follows: $$$##-####-###-###.jpg I'd like to write a script that reads in a list of files... (4 Replies)
Discussion started by: SilversleevesX
4 Replies

4. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

5. Shell Programming and Scripting

Awk to match a pattern and perform a search after the first pattern

Hello Guyz I have been following this forum for a while and the solutions provided are super useful. I currently have a scenario where i need to search for a pattern and start searching by keeping the first pattern as a baseline ABC DEF LMN EFG HIJ LMN OPQ In the above text i need to... (8 Replies)
Discussion started by: RickCharles
8 Replies

6. UNIX for Dummies Questions & Answers

Match Pattern after certain pattern and Print words next to Pattern

Hi experts , im new to Unix,AWK ,and im just not able to get this right. I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Discussion started by: 100bees
2 Replies

7. Shell Programming and Scripting

sed : match one pattern then the next consecutive second pattern not working

Ive used this snippet of code on a solaris box thousands of times. But it isnt working on the new linux box sed -n '/interface LoopBack0/{N;/ ip address /p;}' *.conf its driving me nuts !! Is there something Im missing ? (7 Replies)
Discussion started by: popeye
7 Replies

8. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

9. UNIX for Dummies Questions & Answers

Distinct filenames pattern

Hi All, I am working on designing the archival process for my system, where I will have to find distinct file names ( when excluded time_stamp extention ) from given directory and for each file type keep the latest and move all other older to different location ( lets say dir Back ). Below are... (2 Replies)
Discussion started by: freakabhi
2 Replies

10. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies
XML::PatAct::Amsterdam(3)				User Contributed Perl Documentation				 XML::PatAct::Amsterdam(3)

NAME
XML::PatAct::Amsterdam - An action module for simplistic style-sheets SYNOPSIS
use XML::PatAct::Amsterdam; my $patterns = [ PATTERN => { Before => 'before', After => 'after' }, ... ]; my $matcher = XML::PatAct::Amsterdam->new( I<OPTIONS> ); DESCRIPTION
XML::PatAct::Amsterdam is a PerlSAX handler for applying pattern-action lists to XML parses or trees. XML::PatAct::Amsterdam applies a very simple style sheet to an instance and outputs the result. Amsterdam gets it's name from the Amsterdam SGML Parser (ASP) which inspired this module. CAUTION: Amsterdam is a very simple style module, you will run into it's limitations quickly with even moderately complex XML instances, be aware of and prepared to switch to more complete style modules. New XML::PatAct::Amsterdam instances are creating by calling `new()'. Parameters can be passed as a list of key, value pairs or a hash. A Patterns and Matcher options are required. The following OPTIONS are supported: Patterns The pattern-action list to apply. The list is an anonymous array of pattern, action pairs. Each action in the list contains either or both a Before and an After string to copy to the output before and after processing an XML element. The Before and After strings may contain attribute names enclosed in square brackets (`"["' NAME `"]"'), these are replaced with the value of the attribute with that name. The special NAME `"_element"' will be replaced with the element's name. Matcher An instance of the pattern or query matching module. Output An IO::Handle or one of it's subclasses (such as IO::File), if this parameter is not present and the AsString option is not used, the module will write to standard output. AsString Return the generated output as a string from the `"parse()"' method of the PerlSAX event generator. AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us SEE ALSO
perl(1) ``Using PatAct Modules'' and ``Creating PatAct Modules'' in libxml-perl. perl v5.8.0 2000-02-22 XML::PatAct::Amsterdam(3)
All times are GMT -4. The time now is 07:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy