Sponsored Content
Top Forums Shell Programming and Scripting Shell script to find size of subdirectories Post 302748823 by ankit2012 on Thursday 27th of December 2012 02:49:01 AM
Old 12-27-2012
Hi
Thanks for the reply

Code:
ls -ltr|tail -2|xargs -I '{}' du -sg {}

.Its giving the following result.

Code:
du: drwxr-xr-x    3 oranvd   dba             256 Dec 16 03:30 20121216: A file or directory in the path name does not exist.
du: drwxr-xr-x    3 oranvd   dba             256 Dec 23 03:30 20121223: A file or directory in the path name does not exist.

Its not giving the desired result these folders has files and the size of the same different but its showing only 256 that is not correct.

Last edited by Scrutinizer; 12-27-2012 at 04:21 AM.. Reason: code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to Find file size

Hi, I am writing a script which takes the input file name and concat as a new file by appending a "1" to the file name. However i am not able to get the size of this new file. I am not sure where i am going wrong. Please check the script and help me get this working. #!/bin/sh ... (1 Reply)
Discussion started by: ragsnovel
1 Replies

2. UNIX for Dummies Questions & Answers

shell script to find files by date and size

Hi, I have a directory PRIVATE in which I have several directories and each of these have several files. Therefore, I need to find those files by size and date to back up those files in another directory. I don't know how to implement this shell script using ''find''. appreciate any... (1 Reply)
Discussion started by: dadadc
1 Replies

3. Shell Programming and Scripting

unix script to check whether particular file exists and to find its size

I want to find the size of particular file exists in a particular directory and i wnt to zip it. In the below mentioned code it should check the MQ.log in the particular directory.Please correct my code so that it will check for particular MQ.log but i could not able to check whether the... (9 Replies)
Discussion started by: Balachandar
9 Replies

4. Shell Programming and Scripting

Command/script to find size of Unix Box ?

Please could anyone provide me the Command/script to find the size and usage of Unix box ASAP ? (6 Replies)
Discussion started by: sakthifire
6 Replies

5. Shell Programming and Scripting

Shell Script to find the tablespace size in oracle.

Hi, I need to execute a script to find the tablespace size in oracle.But i get an error.:confused: Script Executed:- #!/bin/ksh ORACLE_SID= oracelinstance ORACLE_HOME= oracle path PATH=$ORACLE_HOME/bin export ORACLE_SID ORACLE_HOME PATH sqlplus... (4 Replies)
Discussion started by: vighna
4 Replies

6. Shell Programming and Scripting

find process size script

Hello i am working on a project here is part of script that i need a help in get process SpectroSERVER current size if it exceed 3850 MB then #pkill -TERM ArchMgr and wait to succfull shutdown message from the log file to proceed to the next step #tail -f $SPECROOT/SS/DDM/ARCHMGR.OUT... (7 Replies)
Discussion started by: mogabr
7 Replies

7. Shell Programming and Scripting

Shell:Find a word in files in a directory and subdirectories

I'm looking to write a ksh code with will be alble to find a word like 'toto' in all files going from my current directory. eg. /doc ----------->have: text.c which "toto" /doc/usr-------->have: build.pc, help.java which "toto" /doc/usr/cach -->have: test.sh which "toto" /doc/build... (4 Replies)
Discussion started by: yeclota
4 Replies

8. UNIX for Dummies Questions & Answers

Command for total number of files (and size) across subdirectories?

Hi all... I have a directory called dbrn. This directory contains an unknown number of subdirectories which in turn contain an unknown number of files. What I want to know is: How many files with extention .ABC can be found in /dbrn across all subdirecties, and what is the total size for... (9 Replies)
Discussion started by: Beun
9 Replies

9. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies
Tree::Simple::Visitor::LoadDirectoryTree(3pm)		User Contributed Perl Documentation	     Tree::Simple::Visitor::LoadDirectoryTree(3pm)

NAME
Tree::Simple::Visitor::LoadDirectoryTree - A Visitor for loading the contents of a directory into a Tree::Simple object SYNOPSIS
use Tree::Simple::Visitor::LoadDirectoryTree; # create a Tree::Simple object whose # node is path to a directory my $tree = Tree::Simple->new("./"); # create an instance of our visitor my $visitor = Tree::Simple::Visitor::LoadDirectoryTree->new(); # set the directory sorting style $visitor->setSortStyle($visitor->SORT_FILES_FIRST); # create node filter to filter # out certain files and directories $visitor->setNodeFilter(sub { my ($item) = @_; return 0 if $item =~ /CVS/; return 1; }); # pass the visitor to a Tree::Simple object $tree->accept($visitor); # the tree now mirrors the structure of the directory DESCRIPTION
This visitor can be used to load a directory tree into a Tree::Simple hierarchy. METHODS
new There are no arguments to the constructor the object will be in its default state. You can use the "setNodeFilter" and "setSortStyle" methods to customize its behavior. setNodeFilter ($filter_function) This method accepts a CODE reference as its $filter_function argument and throws an exception if it is not a code reference. This code reference is used to filter the tree nodes as they are created. The function is given the current directory or file being added to the tree, and it is expected to return either true(1) of false(0) to determine if that directory should be traversed or file added to the tree. setSortStyle ($sort_function) This method accepts a CODE reference as its $sort_function argument and throws an exception if it is not a code reference. This function is used to sort the individual levels of the directory tree right before it is added to the tree being built. The function is passed the the current path, followed by the two items being sorted. The reason for passing the path in is so that sorting operations can be performed on the entire path if desired. Two pre-built functions are supplied and described below. SORT_FILES_FIRST This sorting function will sort files before directories, so that files are sorted alphabetically first in the list followed by directories sorted alphabetically. Here is example of how that would look: Tree/ Simple.pm Simple/ Visitor.pm VisitorFactory.pm Visitor/ PathToRoot.pm SORT_DIRS_FIRST This sorting function will sort directories before files, so that directories are sorted alphabetically first in the list followed by files sorted alphabetically. Here is example of how that would look: Tree/ Simple/ Visitor/ PathToRoot.pm Visitor.pm VisitorFactory.pm Simple.pm visit ($tree) This is the method that is used by Tree::Simple's "accept" method. It can also be used on its own, it requires the $tree argument to be a Tree::Simple object (or derived from a Tree::Simple object), and will throw and exception otherwise. The node value of the $tree argument (gotten by calling "getNodeValue") is considered the root directory from which we begin our traversal. We use File::Spec to keep our paths cross-platform, but it is expected that you will feed in a valid path for your OS. If the path either does not exist, or is not a directory, then an exception is thrown. The $tree argument which is passed to "visit" must be a leaf node. This is because this Visitor will create all the sub-nodes for this tree. If the tree is not a leaf, an exception is thrown. We do not require the tree to be a root though, and this Visitor will not affect any nodes above the $tree argument. BUGS
None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it. CODE COVERAGE
See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more inforamtion. SEE ALSO
These Visitor classes are all subclasses of Tree::Simple::Visitor, which can be found in the Tree::Simple module, you should refer to that module for more information. AUTHOR
stevan little, <stevan@iinteractive.com> COPYRIGHT AND LICENSE
Copyright 2004, 2005 by Infinity Interactive, Inc. <http://www.iinteractive.com> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2005-07-14 Tree::Simple::Visitor::LoadDirectoryTree(3pm)
All times are GMT -4. The time now is 04:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy