Sponsored Content
Top Forums Shell Programming and Scripting Finding missing files that are named sequentially with Perl? Post 302354568 by radoulov on Friday 18th of September 2009 03:36:03 PM
Old 09-18-2009
Something like this:
Code:
perl -le'
    %files = map { ( split "_" )[1] => 1 } glob "*.ARC";
    @seq = sort { $a <=> $b } keys %files;
    print join "\n", grep !$files{$_}, $seq[0] .. $seq[$#seq];
  '

You should adjust the glob for your needs (ARC => txt).

In Perl 5.10 you don't need the hash:

Code:
perl -E'
    @seq = sort { $a <=> $b } map { ( split "_" )[1] } glob "*.ARC";
    for ( $seq[0] .. $seq[$#seq] ) {
        say unless $_ ~~ @seq;
    }'

P.S. Now that I think ..., I'm taking min and max values from the available files.
Is that a correct assumption? What if a file below or above that boundaries is missing?

Last edited by radoulov; 09-18-2009 at 05:40 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

FTP Files Sequentially

Hi Gurus, i have to transfer files one by one from ftp server to target server all files which is to be transferred lies in one ftp folder i have to move those files sequentially from ftp to target and must verify files for successful transmission . then i have to delete corresponding... (1 Reply)
Discussion started by: harim
1 Replies

2. Shell Programming and Scripting

Finding perl files without documentation

I have an application consisting of a number of perl files. I want to find those perl files that have no documentation yet, so I tried the following from the root level of the directory where the application resides: perldoc -r * The output is something like the following: No documentation found... (2 Replies)
Discussion started by: figaro
2 Replies

3. Shell Programming and Scripting

Finding missing tags

I have a list containing strings. All strings should have either "smp" or "drw" else it is considered an error. I have written this code below. Any better ideas to tackle this? set fdrw = 0 set fsmp = 0 foreach f ($Lst) set fdrwtag = `echo $f | awk '/drw/'` set fsmptag = `echo $f | awk... (1 Reply)
Discussion started by: kristinu
1 Replies

4. Shell Programming and Scripting

Finding BEGINNING & ENDING positions of sequentially increasing sublists from a perl numeric array

I have got an Perl array like: @array = (1,2,3,4,5,6,1,2,3,4,1,2,1,2,3,4,5,6,7,8,9...............) This numeric sequence will be always sequentially increasing, unless it encounters, The beginning of the new sequentially increasing numeric sequence. SO in this array we get sequentially... (5 Replies)
Discussion started by: teknokid1
5 Replies

5. Red Hat

Named.conf file missing Centos 5.

hello everyone, I have install centos 5 recently.The file /etc/named.conf not found. I have installed BIND using yum. so now what to do ?? should i create named.conf file manually ??? please help me. thanks, sharlin. :) (1 Reply)
Discussion started by: sharlin
1 Replies

6. Shell Programming and Scripting

perl Compare zone files in directory with what is listed in named.conf

I would really appreciate any assistance that I can get here. I am fairly new to perl. I am trying to rewrite my shell scripts to perl. Currently I have a shell script (using sed, awk, grep, etc) that gets a list of all of the zone files in a directory and then looks in named.conf for what... (0 Replies)
Discussion started by: brianjb
0 Replies

7. Shell Programming and Scripting

[Solved] awk manipulation of sequentially named files

Hello, I am a very novice user of awk, I have a set of files named file001, file002, file003, file004, etc., each contains four fields (columns of data) separated each by a uneven number of spaces. I want to substitute those spaces by a TAB, so I am using this line of awk script: awk -v OFS="\t"... (4 Replies)
Discussion started by: jaldo0805
4 Replies

8. Shell Programming and Scripting

How to introduce the missing number sequentially?

Dear Help, I have an input file which looks like below 002 1000 2000 3000 003 2000 3000 4000 005 1000 2000 6000 I would like to have an output which inserts the missing number in sequential sorting as shown below... 001 0 0 0 002 1000 2000 3000 003 2000 3000 4000 004 0 0 0 005 1000... (5 Replies)
Discussion started by: Indra2011
5 Replies

9. Shell Programming and Scripting

Sequentially rename multiple files

Hello team, We wish to develop a script as follows : 1. Rename multiple files in the following way: example Original file names : test.txt and dummy.txt New file names : test.$(date +"%F").AAAAA<serialno_1>.BBBBBB.p and dummy.$(date +"%F").AAAAA<serialno_2>.BBBBBB.p 2. The... (3 Replies)
Discussion started by: H squared
3 Replies

10. UNIX for Beginners Questions & Answers

Finding Files with Perl on a Hidden Dir?

Greetings! Been a while since I futzed around with Perl, and came upon a minor headscratcher for the community ;) Here's the basic code which I'm trying to make tick over:#!/usr/bin/perl use strict; use warnings; use diagnostics; print " starting "; while (-e "~/.somedir/testFile")... (9 Replies)
Discussion started by: LinQ
9 Replies
TAP::Parser::Scheduler(3)				User Contributed Perl Documentation				 TAP::Parser::Scheduler(3)

NAME
TAP::Parser::Scheduler - Schedule tests during parallel testing VERSION
Version 3.28 SYNOPSIS
use TAP::Parser::Scheduler; DESCRIPTION
METHODS
Class Methods "new" my $sched = TAP::Parser::Scheduler->new(tests => @tests); my $sched = TAP::Parser::Scheduler->new( tests => [ ['t/test_name.t','Test Description'], ... ], rules => \%rules, ); Given 'tests' and optional 'rules' as input, returns a new "TAP::Parser::Scheduler" object. Each member of @tests should be either a a test file name, or a two element arrayref, where the first element is a test file name, and the second element is a test description. By default, we'll use the test name as the description. The optional "rules" attribute provides direction on which tests should be run in parallel and which should be run sequentially. If no rule data structure is provided, a default data structure is used which makes every test eligible to be run in parallel: { par => '**' }, The rules data structure is documented more in the next section. Rules data structure The ""rules"" data structure is the the heart of the scheduler. It allows you to express simple rules like "run all tests in sequence" or "run all tests in parallel except these five tests.". However, the rules structure also supports glob-style pattern matching and recursive definitions, so you can also express arbitarily complicated patterns. The rule must only have one top level key: either 'par' for "parallel" or 'seq' for "sequence". Values must be either strings with possible glob-style matching, or arrayrefs of strings or hashrefs which follow this pattern recursively. Every element in an arrayref directly below a 'par' key is eligible to be run in parallel, while vavalues directly below a 'seq' key must be run in sequence. Rules examples Here are some examples: # All tests be run in parallel (the default rule) { par => '**' }, # Run all tests in sequence, except those starting with "p" { par => 't/p*.t' }, # Run all tests in parallel, except those starting with "p" { seq => [ { seq => 't/p*.t' }, { par => '**' }, ], } # Run some startup tests in sequence, then some parallel tests than some # teardown tests in sequence. { seq => [ { seq => 't/startup/*.t' }, { par => ['t/a/*.t','t/b/*.t','t/c/*.t'], } { seq => 't/shutdown/*.t' }, ], }, Rules resolution o By default, all tests are eligible to be run in parallel. Specifying any of your own rules removes this one. o "First match wins". The first rule that matches a test will be the one that applies. o Any test which does not match a rule will be run in sequence at the end of the run. o The existence of a rule does not imply selecting a test. You must still specify the tests to run. o Specifying a rule to allow tests to run in parallel does not make the run in parallel. You still need specify the number of parallel "jobs" in your Harness object. Glob-style pattern matching for rules We implement our own glob-style pattern matching. Here are the patterns it supports: ** is any number of characters, including /, within a pathname * is zero or more characters within a filename/directory name ? is exactly one character within a filename/directory name {foo,bar,baz} is any of foo, bar or baz. is an escape character Instance Methods "get_all" Get a list of all remaining tests. "get_job" Return the next available job as TAP::Parser::Scheduler::Job object or "undef" if none are available. Returns a TAP::Parser::Scheduler::Spinner if the scheduler still has pending jobs but none are available to run right now. "as_string" Return a human readable representation of the scheduling tree. For example: my @tests = (qw{ t/startup/foo.t t/shutdown/foo.t t/a/foo.t t/b/foo.t t/c/foo.t t/d/foo.t }); my $sched = TAP::Parser::Scheduler->new( tests => @tests, rules => { seq => [ { seq => 't/startup/*.t' }, { par => ['t/a/*.t','t/b/*.t','t/c/*.t'] }, { seq => 't/shutdown/*.t' }, ], }, ); Produces: par: seq: par: seq: par: seq: 't/startup/foo.t' par: seq: 't/a/foo.t' seq: 't/b/foo.t' seq: 't/c/foo.t' par: seq: 't/shutdown/foo.t' 't/d/foo.t' POD ERRORS
Hey! The above document had some coding errors, which are explained below: Around line 102: Unknown directive: =over4 Around line 104: '=item' outside of any '=over' perl v5.16.3 2013-05-02 TAP::Parser::Scheduler(3)
All times are GMT -4. The time now is 09:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy