Sponsored Content
Top Forums Shell Programming and Scripting Help printing files in ascending order of the fi le size (in bytes) Post 302559653 by wessy on Tuesday 27th of September 2011 09:12:42 PM
Old 09-27-2011
Help printing files in ascending order of the fi le size (in bytes)

Hey guys I'm new to unix and need help printing files in a specified directory according to size in bytes as well as files with equal bites in alphabetical order

the part i have done so far prints out all files in the directory as well as setting a time limit in which they have been modified

which looks like
Code:
find $1 -type f -mmin -$(($2*60))

one thing i have tried is
Code:
find $1 -type f -mmin -$(($2*60)) | ls -l |gawk '{print $5,$9|"sort -n"}'

but it seems to be switching the directory and I'm not sure why

anyways if anyone knows where i should start please reply, ty.

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by Franklin52; 09-28-2011 at 04:33 AM.. Reason: Please use code tags, thank you
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Display modified files in ascending order

Hello, i want to display modified files in descending order. "ls -t" will display modified files in descending order. pls help. (1 Reply)
Discussion started by: balareddy
1 Replies

2. UNIX for Advanced & Expert Users

merge two files in ascending order

Hello Friends, I want to merge two files in ascending order on the first field. And if the first field matches sort on 3rd field i.e, TXADDR should come ahead of RXADDR . file1 9 : TXADDR : 00000000 65 : TXDATA 0000000000000011 83 : TXDATA 0000000000000012 453 :... (10 Replies)
Discussion started by: user_prady
10 Replies

3. UNIX for Dummies Questions & Answers

SIZE OF FILES STORE IN WHICH FORMAT bytes or kb in unix?

Hi, i need to know regarding the size type of the files in unix environment.. whether a files or directory will store in which format? kb or bytes ? please answer to my question... thanks & regards, kamal (1 Reply)
Discussion started by: G.K.K
1 Replies

4. Shell Programming and Scripting

list the files with size in bytes

hi all plz help in listing the files with size in bytes. thnks -Bali (4 Replies)
Discussion started by: balireddy_77
4 Replies

5. Shell Programming and Scripting

How to find size 0-4 bytes files?

Hi I need to find and delete 0-4 bytes size files in a folder. How can I achieve that? (1 Reply)
Discussion started by: kapilk
1 Replies

6. Shell Programming and Scripting

How to list all the directories, sub directories in a mount along with size in ascending order?

Hi , I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In a particular mount, have to list all the directories and sub directories along with size of the directory and sub directory in ascending order. Please help me in this regard and many... (4 Replies)
Discussion started by: nmakkena
4 Replies

7. Shell Programming and Scripting

Ascending order

How can I check if array is in ascending order? ---------- Post updated at 01:53 PM ---------- Previous update was at 01:25 PM ---------- Done it now (0 Replies)
Discussion started by: kristinu
0 Replies

8. UNIX for Advanced & Expert Users

How to takes the missing files in ascending order

Hi am using unix aix we have a lots of files which comes from server and fetch in one directory. the files will be in the format as File name as : ------------- pprr0103 (01 as date and 03 as month) pprr0203 pprr0603 ... ... pprr3103 pprr0304 Outputs:- Missing files as... (2 Replies)
Discussion started by: Venkatesh1
2 Replies

9. Shell Programming and Scripting

Unable to list files in ascending order

Hi ! I am just trying to list my files in ascending order so that in some other software, I just want merge with some modification, when I list its coming like this new-10.txt new-11.txt new-12.txt new-13.txt new-14.txt new-15.txt new-16.txt new-17.txt new-18.txt new-19.txt... (2 Replies)
Discussion started by: nex_asp
2 Replies

10. Shell Programming and Scripting

How to list files in ascending order?

Hi, I need to list files in ascending order. Filenames are in format inpTDT_1, inpTDT_2, inpTDT_3 and so on. I want to list them in the ascending order based on the digit after underscore and send the output to a file. Please help (5 Replies)
Discussion started by: Neelkanth
5 Replies
ls(1)							      General Commands Manual							     ls(1)

Name
       ls - list and generate statistics for files

Syntax
       ls [ options ] name ...

Description
       For each directory argument, lists the contents of the directory.  For each file argument, repeats the file name and gives any other infor-
       mation you request with the options available.  By default, the list is sorted alphabetically.  When no	argument  is  given,  the  current
       directory  is  listed.	When several arguments are given, files are listed first, followed by directories and the files within each direc-
       tory.  Options are listed below.

Options
       -1   Displays one entry per line.  This is the default when output is not to a terminal.

       -a   Displays all entries including those beginning with a period (.).

       -C   Forces multicolumn output for pipe or filter.  This is the default when the output is to a terminal.

       -c   Uses time of last file status change (ctime), reflecting file creation, mode, etc., for sorting (with the -t option) or printing (with
	    the -l option) rather than the time of file modification or access. See also the -t and -u options.

       -d   Displays names of directories only, not contents.  Use this option with -l to get the status of a directory.

       -F   Marks  directories	with  trailing	slash (/), sockets with a trailing equal sign (=), symbolic links with a trailing at sign (@), and
	    executable files with a trailing asterisk (*).

       -f   Displays names in the order they exist in directory.  For further information, see Entries	beginning  with  a  period  (.)  are  also
	    listed.  This option overrides the -l, -t, -s, and -r options.

       -g   Displays assigned group ID (used with -l only).  Default is assigned owner ID.

       -i   Displays the i-number for each file in the first column of the report.

       -L   Lists  the	information,  if  the file is a symbolic link, for the file or directory the link references rather than that for the link
	    itself.

       -l   Lists the mode, number of links, owner, size in bytes, and time of last modification (mtime) for each file.  If the file is a  special
	    file, the size field contains the major and minor device numbers instead of the size.  If the file is a symbolic link, the pathname of
	    the linked-to file is printed, preceded by ``->''.

	    The mode field consists of 11 characters.  The first character indicates the type of entry:

	    d if the entry is a directory
	    b if the entry is a block-type special file
	    c if the entry is a character-type special file
	    l if the entry is a symbolic link
	    s if the entry is a socket
	    - if the entry is a plain file

	    The next 9 characters are interpreted as three sets of three characters each.  The first set of three characters refers to file-access
	    permissions  for  the user; the next set, for the user-group; and the last set, for all others.  The permissions are indicated as fol-
	    lows:

	    r if the file is readable
	    w if the file is writable
	    x if the file is executable
	    - if the indicated permission is not granted.

	    The group-execute permission character is given as s if the file has the set-group-id bit set; likewise, the  user-execute	permission
	    character is given as s if the file has the set-user-id bit set.

	    The last character of the mode (normally `x' or `-') is t if the 1000 bit of the mode is on.  See for the meaning of this mode.

       -q   Forces  the printing of nongraphic characters in file names as the question mark character (?).  This is the default when output is to
	    a terminal.

       -R   Recursively lists all subdirectories.

       -r   Sorts entries in reverse alphabetic or time order.

       -s   Displays the size in kilobytes of each file.  This is the first item listed in each entry.

       -t   Sorts by time modified (most recently modified first) instead of by name. See also the -c and -u options.

       -u   Uses the time of last access (atime) instead of last modification for sorting (with the -t option) or printing (with the -l option).

Restrictions
       The output device is assumed to be 80 columns wide.

       New line and tab are considered printing characters in file names.

       The option setting based on whether the output is a teletype is undesirable as "ls -s" is much different than "ls -s |lpr".  On	the  other
       hand, not doing this setting would make old shell scripts which used ls almost certain to fail.

Files
       Used to obtain user id's for ls -l

       Used to obtain group id's for ls -g

See Also
       stat(2)

																	     ls(1)
All times are GMT -4. The time now is 10:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy