Sponsored Content
Top Forums Shell Programming and Scripting Multiple Files deletion in perl Post 302166518 by pulkit on Tuesday 12th of February 2008 04:48:48 AM
Old 02-12-2008
Multiple Files deletion in perl

Hello Friends,

I want to delete all the "*.trg" files in a directory but i don't want to do it by

system("rm -r *.trg");

Can i do it thru unlink or by any other mean

Thanks,
Pulkit
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding 3 Lines to Multiple c and h files with perl

Hello, i need some help with a perl script. i need to add the lines: #ifdef LOGALLOC #include "logalloc.h" #endif // LOGALLOC To all c and h files in a project with subdirectories. Logalloc is a tool to log all *alloc and free's in a text file, it defines the *alloc funtions new.... (2 Replies)
Discussion started by: Lazzar
2 Replies

2. Shell Programming and Scripting

Combining Multiple files in one in a perl script

All, I want to combine multiple files in one file. Something like what we do on the commad line as follows -> cat file1 file2 file3 > Main_File. Can something like this be done in a perl script very efficiently? Thanks, Rahul. (1 Reply)
Discussion started by: rahulrathod
1 Replies

3. Shell Programming and Scripting

Regarding deletion of old files

Hi, I have a list of directories which contain old files that are to be deleted. I put the list of all directories in a txt file and it is being read by a script Iam searching for the files older than 60 days using mtime and then deleting it But all the files are getting deleted... (3 Replies)
Discussion started by: Chidvilas
3 Replies

4. Shell Programming and Scripting

Perl program to read from multiple files

Hi, I need to generate a test data file by reading inputs from multiple files. A sample pseudo code for this program to read from three files and write to a output file would be like: open(OUTPUTFILE, "data"); open(INFILE1, "data1"); open(INFILE2, "data2"); open(INFILE3, "data3"); ... (1 Reply)
Discussion started by: jyotipg
1 Replies

5. UNIX for Dummies Questions & Answers

Line deletion help using perl -ne

Hi all, I know the one liner to delete all the lines in a file which matches a pattern i.e perl -i.old -ne 'print unless /pattern/' file Now i need the perl onliner to delete all the lines which doesnt match the pattern. Also what is the difference between perl -i and perl -i.old. Does... (1 Reply)
Discussion started by: lijju.mathew
1 Replies

6. Shell Programming and Scripting

blank line deletion in a file using perl

Dear All, I am looking for an option in perl using which i could delete empty lines in a file. Or the alternative of sed '/^$/d' <filename> in perl. Sed is not working in my perl script :( Pls help me out . Thanks, VG (4 Replies)
Discussion started by: vguleria
4 Replies

7. Shell Programming and Scripting

perl script on multiple files

I have a script that runs on one file (at a time). like this: $> perl myscript.pl filename > output How can I run it on >6000 files and have the output sent out into slightly modified file name $> perl myscript 6000files> output6000files.new extension Thanks in anticipation (4 Replies)
Discussion started by: aritakum
4 Replies

8. UNIX for Dummies Questions & Answers

Grep in Perl - Searching through multiple files

I'm attempting to use grep in Perl with very little success. What I would like to do in Perl is get the output of the following grep code: grep -l 'pattern' * This gives me a list of all the files in a directory that contain the pattern that was searched. My attempts to do this in Perl... (4 Replies)
Discussion started by: WongSifu
4 Replies

9. Shell Programming and Scripting

perl: search replace in multiple files

When I use special characters the command to replace multiple files with a string pattern does nt work. ---------- Post updated at 12:33 PM ---------- Previous update was at 11:38 AM ---------- This works perl -pi -e 's/100/test/g' * This does nt work perl -pi -e 's... (1 Reply)
Discussion started by: w020637
1 Replies

10. Shell Programming and Scripting

deletion of multiple occurring files

Hi all, In the given file, what I need to do is to select double (or triple) occurring files and delete the one having smaller file size. And would like to keep the one with the big file size. 518t-rw-r--r-- 1 emily us_cms 101348458 Oct 8 16:43 vgtree_518_0_LHB.root 518t-rw-r--r-- 1... (9 Replies)
Discussion started by: emily
9 Replies
ExtUtils::Command(3pm)					 Perl Programmers Reference Guide				    ExtUtils::Command(3pm)

NAME
ExtUtils::Command - utilities to replace common UNIX commands in Makefiles etc. SYNOPSIS
perl -MExtUtils::Command -e cat files... > destination perl -MExtUtils::Command -e mv source... destination perl -MExtUtils::Command -e cp source... destination perl -MExtUtils::Command -e touch files... perl -MExtUtils::Command -e rm_f files... perl -MExtUtils::Command -e rm_rf directories... perl -MExtUtils::Command -e mkpath directories... perl -MExtUtils::Command -e eqtime source destination perl -MExtUtils::Command -e test_f file perl -MExtUtils::Command -e test_d directory perl -MExtUtils::Command -e chmod mode files... ... DESCRIPTION
The module is used to replace common UNIX commands. In all cases the functions work from @ARGV rather than taking arguments. This makes them easier to deal with in Makefiles. Call them like this: perl -MExtUtils::Command -e some_command some files to work on and NOT like this: perl -MExtUtils::Command -e 'some_command qw(some files to work on)' For that use Shell::Command. Filenames with * and ? will be glob expanded. FUNCTIONS cat cat file ... Concatenates all files mentioned on command line to STDOUT. eqtime eqtime source destination Sets modified time of destination to that of source. rm_rf rm_rf files or directories ... Removes files and directories - recursively (even if readonly) rm_f rm_f file ... Removes files (even if readonly) touch touch file ... Makes files exist, with current timestamp mv mv source_file destination_file mv source_file source_file destination_dir Moves source to destination. Multiple sources are allowed if destination is an existing directory. Returns true if all moves succeeded, false otherwise. cp cp source_file destination_file cp source_file source_file destination_dir Copies sources to the destination. Multiple sources are allowed if destination is an existing directory. Returns true if all copies succeeded, false otherwise. chmod chmod mode files ... Sets UNIX like permissions 'mode' on all the files. e.g. 0666 mkpath mkpath directory ... Creates directories, including any parent directories. test_f test_f file Tests if a file exists. Exits with 0 if it does, 1 if it does not (ie. shell's idea of true and false). test_d test_d directory Tests if a directory exists. Exits with 0 if it does, 1 if it does not (ie. shell's idea of true and false). dos2unix dos2unix files or dirs ... Converts DOS and OS/2 linefeeds to Unix style recursively. SEE ALSO
Shell::Command which is these same functions but take arguments normally. AUTHOR
Nick Ing-Simmons "ni-s@cpan.org" Maintained by Michael G Schwern "schwern@pobox.com" within the ExtUtils-MakeMaker package and, as a separate CPAN package, by Randy Kobes "r.kobes@uwinnipeg.ca". perl v5.18.2 2014-01-06 ExtUtils::Command(3pm)
All times are GMT -4. The time now is 10:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy