Sponsored Content
Homework and Emergencies Homework & Coursework Questions Sorting files by size in another directory Post 302900094 by Don Cragun on Sunday 4th of May 2014 05:36:13 AM
Old 05-04-2014
Each call to system() creates a separate shell execution environment. Once the commands given to a call to system() complete, that environment is gone.

So, if you call system two times:
Code:
    system("cd some_directory");
    system("ls -al | sort -k5n");

the first call will not affect the directory in which the second call is run. But, if you perform the cd and the ls and sort pipeline in the same call to system() as in:
Code:
    system("cd some_directory
        ls -al | sort -k5n");
                or
    system("cd some_directory; ls -al | sort -k5n");

then the cd command will affect the directory where the pipeline executes.

Do you want the primary sort key of your output to be the file size and the secondary sort key to be the file type? Would you prefer to sort the output with the primary sort key being the file size and the secondary sort key being the file name? Have you looked at all of the options that the ls utility accepts on your system? Do you need both ls and sort? Is there an option to ls that will sort the output by file size and file name instead of having the primary sort key be the file name? If that output is backwards, is there an option to reverse the order of the output produced by ls?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check if 3 files have same size in directory

I need to determine if any three files have the same file size in a specified directly? I have got as far as listing the file sizes but where to go from here? ls -al |sort -n -r +4 | awq '{print $5}' Thanks in anticipation (5 Replies)
Discussion started by: oggle
5 Replies

2. Shell Programming and Scripting

Sorting files in a directory

Hi guys, Probably an easy one, but how do you sort a directory so that the files come first, then subdirectories? ie ./dir1 contains file 1 subdir 1 file 2 i need it to become file 1 file 2 subdir 1 as i'm using it in a script to pass each one through a for loop, and would... (2 Replies)
Discussion started by: olimiles
2 Replies

3. UNIX for Dummies Questions & Answers

Sorting files in a directory

Hi guys, Probably an easy one, but how do you sort a directory so that the files come first, then subdirectories? ie ./dir1 has file 1 subdir 1 file 2 i need it to become file 1 file 2 subdir 1 as i'm using it in a script to pass each one through a for loop, and would like all... (3 Replies)
Discussion started by: olimiles
3 Replies

4. Shell Programming and Scripting

files of size 0 need to be deleted inside a directory

Hiiii, I have written a script which takes backup of some log files. let say the backuplocation is --- /abc/backuplocation -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt23994.log -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt3601.log -rw-r--r-- 1... (2 Replies)
Discussion started by: namishtiwari
2 Replies

5. UNIX for Dummies Questions & Answers

listing files in a directory in bases of size

Hi , I want to list all files in the order of size . Just want to know which files occupies more size and which occupies less size . Is it possible with ls command ? :) Thanks, Arun. (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

6. UNIX for Dummies Questions & Answers

Cp files (>5 Mb size) from one directory to another

Hi All, I have a requirement like below, I want to transfer few file of size > 5 Mb from one directory to anotehr directory. Please let me know the command how can i do that Sorry if it looks silly Senthil (6 Replies)
Discussion started by: skcontact
6 Replies

7. Shell Programming and Scripting

Getting the total file size for certain files per directory

Hi, I am trying to get the total file size for certain files per directory. I am using find /DirectoryPath -name '*.dta' -exec ls -l {} \; | awk '{ print $NF ": " $5 }' > /users/cergun/My\ Documents/dtafiles.txt but this lists all the files in the directories. I need the total... (9 Replies)
Discussion started by: cergun
9 Replies

8. Shell Programming and Scripting

Sorting files by size. No ls.

I've got an assignment where I've made a script that searched and found files that meet certain requirement. (Files that are a size that is from "x" to "y" in size and has a certain name). The script sends the output to a file that gathers the info. The problem is I'd like to sort what's... (3 Replies)
Discussion started by: BobbyTee
3 Replies

9. UNIX for Dummies Questions & Answers

How to get the set of files size as a sum in a directory.

Hi, Can someone help me to get the complete files size (sum) over a perod time (1 day,2days)in a directory. eg: Directory :ABC I have a1,a2,a3 files are created in last 24 hours so I need to get the some of all these files. I am using the below find command but its giving me the... (1 Reply)
Discussion started by: gaddamja
1 Replies

10. 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
SVN::Web::I18N(3pm)					User Contributed Perl Documentation				       SVN::Web::I18N(3pm)

NAME
SVN::Web::I18N - SVN::Web internationalisation class SYNOPSIS
use SVN::Web::I18N; # Nothing exported # Add a directory that contains .po and/or .mo files SVN::Web::I18N::add_directory('/path/to/directory'); # Specify the current language SVN::Web::I18N::loc_lang('en'); # Get a translated string my $xlated = SVN::Web::I18N::loc('(a string to translate)'); DESCRIPTION
SVN::Web::I18N provides the interface through which SVN::Web is internationalised, and how different localisations are implemented. SUBROUTINES
SVN::Web::I18N::add_directory($path) Adds a new directory to the list of directories in which localisations will be found. Any *.po and *.mo files in this directory will automatically be scanned for localisations, and added to the language key given by the file's basename. In case where two different directories both contain a localisation file that defines the same localisation key for the same language, the localisation key from the most recently added directory will be used. SVN::Web::I18N::loc_lang($lang) Selects the language to use for subsequent calls to "loc()". The $lang parameter should be a valid language name -- i.e., there must exist at least one $lang.po file in one of the directories used in a call to "SVN::Web::I18N::add_directory()". SVN::Web::I18N::loc($text) and SVN::Web::I18N::loc($text, $param1, ...) Returns the localised form of $text according to the localisation selected by the most recent call to "loc_lang()". If the localisation expects parameters to fill in the localisation result they should be passed as the second and subsequent arguments. If $text does not have a defined localised form it is returned with the parameters interpolated in to it. SEE ALSO
Locale::Maketext, Locale::Maketext::Lexicon, SVN::Web AUTHORS
Nik Clayton "<nik@FreeBSD.org>" COPYRIGHT
Copyright 2006-2007 by Nik Clayton "<nik@FreeBSD.org>". This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html> perl v5.14.2 2012-06-11 SVN::Web::I18N(3pm)
All times are GMT -4. The time now is 02:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy