Sponsored Content
Top Forums Shell Programming and Scripting deleting all files with 0 size Post 302453164 by kurumi on Tuesday 14th of September 2010 08:18:06 AM
Old 09-14-2010
Code:
ruby -e 'Dir["**/**"].each{|f| File.unlink(f) if File.size(f)==0}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies

2. Shell Programming and Scripting

Checking files size and deleting if bigger than x

Hello , I have to write a crontab line make a check on a file and, if bigger than 2Gb, to stop apache daemon, delete the file and restart apache . Someone have suggestions ? Thanks (2 Replies)
Discussion started by: gogol_bordello
2 Replies

3. Shell Programming and Scripting

Merge files of differrent size with one field common in both files using awk

hi, i am facing a problem in merging two files using awk, the problem is as stated below, file1: A|B|C|D|E|F|G|H|I|1 M|N|O|P|Q|R|S|T|U|2 AA|BB|CC|DD|EE|FF|GG|HH|II|1 .... .... .... file2 : 1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies

4. Shell Programming and Scripting

Deleting files

hellooo..... script is: To remove a file from a directory if a starting letter and a file size is given by the user. My code is: echo "Enter a letter" read l echo "Enter Size" read size for i in `ls $l*` do s=`stat -c %s $i` if then rm $i ... (1 Reply)
Discussion started by: Priyanka Bhati
1 Replies

5. Shell Programming and Scripting

Deleting files based on their size

I have several files in a folder and I would like to delete the ones that do not contain all the required information (size) let say 1kb. Any ideas? (4 Replies)
Discussion started by: Xterra
4 Replies

6. Shell Programming and Scripting

Need help comparing two files and deleting some things in those files!

So I have two files: File1 pictures.txt 1.1 1.3 dance.txt 1.2 1.4 treehouse.txt 1.3 1.5 File2 pictures.txt 1.5 ref2313 1.4 ref2345 1.3 ref5432 1.2 ref4244 dance.txt 1.6 ref2342 1.5 ref2352 1.4 ref0695 1.3 ref5738 1.2 ref4948 1.1 treehouse.txt 1.6 ref8573 1.5 ref3284 1.4 ref5838... (24 Replies)
Discussion started by: linuxkid
24 Replies

7. Shell Programming and Scripting

AIX system.... deleting files in remote directory after retrieving files

Hi Friends, I am new to this , I am working on AIX system and my scenario is to retrive the files from remote system and remove the files from the remote system after retreving files. I can able to retrieve the files but Can't remove files in remote system. Please check my code and help me out... (3 Replies)
Discussion started by: vinayparakala
3 Replies

8. Shell Programming and Scripting

Deleting files

Hi all, I have developed a shell script to copy the files from source to destination and simultaneously to delete the copied files in source. I can copy the files but the files cannot be deleted in source side. (3 Replies)
Discussion started by: Venkatesan
3 Replies

9. Shell Programming and Scripting

How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir (0 Replies)
Discussion started by: shaal89
0 Replies

10. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies
File::Fu(3pm)						User Contributed Perl Documentation					     File::Fu(3pm)

NAME
File::Fu - file and directory objects SYNOPSIS
The directory constructor: use File::Fu; my $dir = File::Fu->dir("bar"); print "$dir "; # 'bar/' my $file = $dir + 'bar.txt'; print "$file "; # 'bar/bar.txt' my $d2 = $dir % 'baz'; # 'barbaz/' my $d3 = $dir / 'bat'; # 'bar/bat/' my $file2 = $dir / 'bat' + 'foo.txt'; # 'bar/bat/foo.txt' The file constructor: my $file = File::Fu->file("foo"); $file->e and warn "$file exists"; $file->l and warn "$file is a link"; warn "file is in ", $file->dir; ABOUT
This class provides the toplevel interface to File::Fu directory and file objects, with operator overloading which allows precise path composition and support for most builtin methods, as well as creation of temporary files/directories, finding files, and more. The interface and style are quite different than the perl builtins or File::Spec. The syntax is concise. Errors are thrown with croak(), so you never need to check a return code. Constructors The actual objects are in the 'Dir' and 'File' sub-namespaces. dir my $dir = File::Fu->dir($path); See "new" in File::Fu::Dir file my $file = File::Fu->file($path); See "new" in File::Fu::File Class Constants tmp Your system's '/tmp/' directory (or equivalent of that.) my $dir = File::Fu->tmp; home User's $HOME directory. my $dir = File::Fu->home; program_name The absolute name of your program. This will be relative from the time File::Fu was loaded. It dies if the name is '-e'. my $prog = File::Fu->program_name; If File::Fu was loaded after a chdir and the $0 was relative, calling program_name() throws an error. (Unless you set $0 correctly before requiring File::Fu.) program_dir Returns what typically corresponds to program_name()->dirname, but just the compile-time cwd() when $0 is -e/-E. my $dir = File::Fu->program_dir; Class Methods THIS_FILE A nicer way to say __FILE__. my $file = File::Fu->THIS_FILE; cwd The current working directory. my $dir = File::Fu->cwd; which Returns File::Fu::File objects of ordered candidates for $name found in the path. my @prog = File::Fu->which($name) or die "cannot find $name"; If called in scalar context, returns a single File::Fu::File object or throws an error if no candidates were found. my $prog = File::Fu->which($name); Temporary Directories and Files These class methods call the corresponding File::Fu::Dir methods on the value of tmp(). That is, you get a temporary file/dir in the '/tmp/' directory. temp_dir my $dir = File::Fu->temp_dir; temp_file my $handle = File::Fu->temp_file; Subclassing You may wish to subclass File:Fu and override the dir_class() and/or file_class() class methods to point to your own Dir/File subclasses. my $class = 'My::FileFu'; my $dir = $class->dir("foo"); See File::Fu::File and File::Fu::Dir for more info. See Also File::Fu::why if I need to explain my motivations. Path::Class, from which many an idea was taken. File::stat, IO::File, File::Spec, File::Find, File::Temp, File::Path, File::Basename, perlfunc, perlopentut. AUTHOR
Eric Wilhelm @ <ewilhelm at cpan dot org> http://scratchcomputing.com/ BUGS
If you found this module on CPAN, please report any bugs or feature requests through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. If you pulled this development version from my /svn/, please contact me directly. COPYRIGHT
Copyright (C) 2008 Eric L. Wilhelm, All Rights Reserved. NO WARRANTY
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned. LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-05-13 File::Fu(3pm)
All times are GMT -4. The time now is 03:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy