Sponsored Content
Operating Systems Linux Remove matching files from a list Post 302895018 by renuk on Friday 28th of March 2014 09:08:26 AM
Old 03-28-2014
Remove matching files from a list

hi,

i have a cache file with below file list
Code:
 more gtda_11.cache
GTDA_Dly_Pmix_GB_6_20130624.20130624070610.psv
GTDA_Dly_Pmix_CH_006_20130624.20130624140018.psv
GTDA_Dly_Pmix_GB_6_20130624.20130624070620.psv
GTDA_Dly_Pmix_BE_6_20130624.20130624070620.psv
GTDA_Dly_Pmix_CA_66_20130624.20130624140018.psv

I have other file ABaC.csv with below file list:
Code:
GTDA_Dly_Pmix_CH_006_20130624.20130624140018.psv
GTDA_Dly_Pmix_BE_6_20130624.20130624070620.psv

i want to remove files from gtda_11.cache which are matching with ABaC.csv
i.e : GTDA_Dly_Pmix_CH_006_20130624.20130624140018.psv
GTDA_Dly_Pmix_BE_6_20130624.20130624070620.psv

final out should be:
Code:
more gtda_11.cache
GTDA_Dly_Pmix_GB_6_20130624.20130624070610.psv
GTDA_Dly_Pmix_GB_6_20130624.20130624070620.psv
GTDA_Dly_Pmix_CA_66_20130624.20130624140018.psv

Thanks in advance!!
Smilie

Last edited by vbe; 03-28-2014 at 10:32 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Too many files to list / remove

I have a directory which has 614,000 files. When attempting to do an ls -ralt in the directory an error too many arguments is shown. 1. I would like to see what files and their stats in the directory 2. I would like to delete certain files of a certain age (3 Replies)
Discussion started by: dinplant
3 Replies

2. UNIX for Advanced & Expert Users

Can't list or remove files from a directory

Hi I have a problem. One of the directories in /var, on one of my servers, has filled up with loads of files. I have tried to list the directory to see what is in it, but the 'ls' command just hangs. Same thing happens when I try to use 'rm' to remove files from that directory. I can see what... (2 Replies)
Discussion started by: m_smith
2 Replies

3. Shell Programming and Scripting

Remove matching lines with list of strings

Hi, HP-UX gxxxxxxxc B.11.23 U ia64 3717505098 unlimited-user license I have a file with below pipe separated field values: xxx|xxx|abcd|xxx|xxx|xx xxx|xxx|abcd#123|xxx|xxx|xx xxx|xxx|abcd#345|xxx|xxx|xx xxx|xxx|pqrs|xxx|xxx|xx xxx|xxx|pqrs#123|xxx|xxx|xx The third field has values like... (6 Replies)
Discussion started by: Nanu_Manju
6 Replies

4. Shell Programming and Scripting

compare two files and to remove the matching lines on both the files

I have two files and need to compare the two files and to remove the matching lines from both the files (4 Replies)
Discussion started by: shellscripter
4 Replies

5. UNIX for Dummies Questions & Answers

remove characters from list of files

done some homework on this-- after i remove up to and including the ) i want to take newfile.txt and use that list to remove the files from a file in my the directory pwd i have a input.txt file cat input,txt 1)mary.jpg 12)john.jpg 100)frankkfkdf .jpg i want to remove the characters in the... (1 Reply)
Discussion started by: plener
1 Replies

6. Shell Programming and Scripting

Remove first row in a list of files

Hi I want to remove the first row in a list of files and am trying to do via the following. I've tried various quotes to redirect the modifed file to a newly named version of itself but no joy. Can you help? > for i in 'ls A*'; do sed '1d' $i > $i"_complete"; done bash: $i"_complete":... (4 Replies)
Discussion started by: ksexton
4 Replies

7. UNIX for Dummies Questions & Answers

Script to list non matching files using pattern

Hi, I am trying to write a script that list down all the files that do not match the pattern My pattern will be like this "*.jpg|*.xml|*.sql". This pattern will be stored in a file. The script need to read this pattern from the file and delete the files that does not match this pattern. It... (7 Replies)
Discussion started by: meenavin
7 Replies

8. Shell Programming and Scripting

list files not matching wild card

Hi I need a unix command which generates the list of files that dont match the wild card pattern in the current directory say for example I have files like x.addfd.txt.H2012.txt x.addfd.txt.H2012.txt x.asegfd.txt.H2012.txt adfd.bagddf I need the list of files which dont match... (4 Replies)
Discussion started by: lijjumathew
4 Replies

9. UNIX for Dummies Questions & Answers

List all files with sum of matching word

grep -c 'avihai' 1.log will give me count of 'avihai' in log I want to have a list of files in the folder that show file name with count side by side. Please advice (2 Replies)
Discussion started by: avihaimar
2 Replies

10. Shell Programming and Scripting

awk to combine all matching dates and remove non-matching

Using the awk below I am able to combine all the matching dates in $1, but I can not seem to remove the non-matching from the file. Thank you :). file 20161109104500.0+0000,x,5631 20161109104500.0+0000,y,2 20161109104500.0+0000,z,2 20161109104500.0+0000,a,4117... (3 Replies)
Discussion started by: cmccabe
3 Replies
Getopt::Long::Descriptive(3)				User Contributed Perl Documentation			      Getopt::Long::Descriptive(3)

NAME
Getopt::Long::Descriptive - Getopt::Long, but simpler and more powerful VERSION
version 0.096 SYNOPSIS
use Getopt::Long::Descriptive; my ($opt, $usage) = describe_options( 'my-program %o <some-arg>', [ 'server|s=s', "the server to connect to", { required => 1 } ], [ 'port|p=i', "the port to connect to", { default => 79 } ], [], [ 'verbose|v', "print extra stuff" ], [ 'help', "print usage message and exit" ], ); print($usage->text), exit if $opt->help; Client->connect( $opt->server, $opt->port ); print "Connected! " if $opt->verbose; ...and running "my-program --help" will produce: my-program [-psv] [long options...] <some-arg> -s --server the server to connect to -p --port the port to connect to -v --verbose print extra stuff --help print usage message and exit DESCRIPTION
Getopt::Long::Descriptive is yet another Getopt library. It's built atop Getopt::Long, and gets a lot of its features, but tries to avoid making you think about its huge array of options. It also provides usage (help) messages, data validation, and a few other useful features. FUNCTIONS
Getopt::Long::Descriptive only exports one routine by default: "describe_options". All GLD's exports are exported by Sub::Exporter. describe_options my ($opt, $usage) = describe_options($usage_desc, @opt_spec, \%arg); This routine inspects @ARGV for options that match the supplied spec. If all the options are valid then it returns the options given and an object for generating usage messages; if not then it dies with an explanation of what was wrong and a usage message. The $opt object will be a dynamically-generated subclass of Getopt::Long::Descriptive::Opts. In brief, each of the options in @opt_spec becomes an accessor method on the object, using the first-given name, with dashes converted to underscores. For more information, see the documentation for the Opts class. The $usage object will be a Getopt::Long::Descriptive::Usage object, which provides a "text" method to get the text of the usage message and "die" to die with it. For more methods and options, consults the documentation for the Usage class. $usage_desc The $usage_desc parameter to "describe_options" is a "sprintf"-like string that is used in generating the first line of the usage message. It's a one-line summary of how the command is to be invoked. A typical usage description might be: $usage_desc = "%c %o <source> <desc>"; %c will be replaced with what Getopt::Long::Descriptive thinks is the program name (it's computed from $0, see "prog_name"). %o will be replaced with a list of the short options, as well as the text "[long options...]" if any have been defined. The rest of the usage description can be used to summarize what arguments are expected to follow the program's options, and is entirely free-form. Literal "%" characters will need to be written as "%%", just like with "sprintf". @opt_spec The @opt_spec part of the args to "describe_options" is used to configure option parsing and to produce the usage message. Each entry in the list is an arrayref describing one option, like this: @opt_spec = ( [ "verbose|V" => "be noisy" ], [ "logfile=s" => "file to log to" ], ); The first value in the arrayref is a Getopt::Long-style option specification. In brief, they work like this: each one is a pipe-delimited list of names, optionally followed by a type declaration. Type declarations are '=x' or ':x', where "=" means a value is required and ":" means it is optional. x may be 's' to indicate a string is required, 'i' for an integer, or 'f' for a number with a fractional part. The type spec may end in "@" to indicate that the option may appear multiple times. For more information on how these work, see the Getopt::Long documentation. The first name given should be the canonical name, as it will be used as the accessor method on the $opt object. Dashes in the name will be converted to underscores, and all letters will be lowercased. For this reason, all options should generally have a long-form name. The second value in the arrayref is a description of the option, for use in the usage message. Special Option Specifications If the option specification (arrayref) is empty, it will have no effect other than causing a blank line to appear in the usage message. If the option specification contains only one element, it will be printed in the usage message with no other effect. If the option specification contains a third element, it adds extra constraints or modifiers to the interpretation and validation of the value. These are the keys that may be present in that hashref, and how they behave: implies implies => 'bar' implies => [qw(foo bar)] implies => { foo => 1, bar => 2 } If option A has an "implies" entry, then if A is given, other options will be enabled. The value may be a single option to set, an arrayref of options to set, or a hashref of options to set to specific values. required required => 1 If an option is required, failure to provide the option will result in "describe_options" printing the usage message and exiting. hidden hidden => 1 This option will not show up in the usage text. You can achieve the same behavior by using the string "hidden" for the option's description. one_of one_of => @subopt_specs This is useful for a group of options that are related. Each option spec is added to the list for normal parsing and validation. Your option name will end up with a value of the name of the option that was chosen. For example, given the following spec: [ "mode" => hidden => { one_of => [ [ "get|g" => "get the value" ], [ "set|s" => "set the value" ], [ "delete" => "delete it" ], ] } ], No usage text for 'mode' will be displayed, but text for get, set, and delete will be displayed. If more than one of get, set, or delete is given, an error will be thrown. So, given the @opt_spec above, and an @ARGV of "('--get')", the following would be true: $opt->get == 1; $opt->mode eq 'get'; Note: "get" would not be set if "mode" defaulted to 'get' and no arguments were passed in. Even though the option sub-specs for "one_of" are meant to be 'first class' specs, some options don't make sense with them, e.g. "required". As a further shorthand, you may specify "one_of" options using this form: [ mode => @option_specs, \%constraints ] shortcircuit shortcircuit => 1 If this option is present no other options will be returned. Other options present will be checked for proper types, but not for constraints. This provides a way of specifying "--help" style options. Params::Validate In addition, any constraint understood by Params::Validate may be used. (Internally, all constraints are translated into Params::Validate options or callbacks.) %arg The %arg to "describe_options" is optional. If the last parameter is a hashref, it contains extra arguments to modify the way "describe_options" works. Valid arguments are: getopt_conf - an arrayref of strings, passed to Getopt::Long::Configure prog_name This routine, exported on demand, returns the basename of $0, grabbed at compile-time. You can override this guess by calling "prog_name($string)" yourself. OTHER EXPORTS
"-types" Any of the Params::Validate type constants ("SCALAR", etc.) can be imported as well. You can get all of them at once by importing "-types". "-all" This import group will import "-type", "describe_options", and "prog_name". CUSTOMIZING
Getopt::Long::Descriptive uses Sub::Exporter to build and export the "describe_options" routine. By writing a new class that extends Getopt::Long::Descriptive, the behavior of the constructed "describe_options" routine can be changed. The following methods can be overridden: usage_class my $class = Getopt::Long::Descriptive->usage_class; This returns the class to be used for constructing a Usage object, and defaults to Getopt::Long::Descriptive::Usage. SEE ALSO
o Getopt::Long o Params::Validate AUTHORS
o Hans Dieter Pearcey <hdp@cpan.org> o Ricardo Signes <rjbs@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2005 by Hans Dieter Pearcey. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.18.2 2013-10-04 Getopt::Long::Descriptive(3)
All times are GMT -4. The time now is 12:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy