Sponsored Content
Full Discussion: Sort by file/directory size
Top Forums UNIX for Beginners Questions & Answers Sort by file/directory size Post 303013450 by wbport on Wednesday 21st of February 2018 01:51:36 PM
Old 02-21-2018
We call this script lz to sort by sizes.
Code:
rev=""
if [ $# -gt 0 ]
  then
  if [ $1 = '-r' ]
  then
    rev="r"
#   echo $rev
    shift
  fi
fi
ls -l $* |grep -v "total " |sort +4n$rev -5 +8 |more -e

In case of a tie, the file names are alphabetical.
This User Gave Thanks to wbport For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File size limitation of unix sort command.

hi , iam trying to sort millions of records which is delimited and i cant able to use sort command more than 60 million..if i try to do so i got an message stating that "File size limit exceeded",Is there any file size limit for using sort command.. How can i solve this problem. thanks ... (7 Replies)
Discussion started by: cskumar
7 Replies

2. Shell Programming and Scripting

How to know size of file in a directory

Hi, I have to directory /usr/inbound ------------- 10900.txt 10889.txt 109290202.txt I need to create inbound directory and i need to know size of these files one by one if file size is zero i need to print message like "empty file" Please help me how to solve this thanks krish. (1 Reply)
Discussion started by: kittusri9
1 Replies

3. UNIX for Dummies Questions & Answers

How can I sort the file names in the directory

Hi , I have a list of files in the directory I want to sort based on the file name. But in the middle of filename contains the number based on that I need to sort.Could you suggest me on the same? Example filenames: /user1$ls RS.DEV.ISV.F1.RS.REFDATA.DATA... (1 Reply)
Discussion started by: praveen.thumati
1 Replies

4. UNIX for Dummies Questions & Answers

Sort by size, then list file in each directory

Hi, I have directories with name like: aaa bbb ccc ... I would like to to see which directories are the largest and then list the files within each. I have success using: du -ks * | sort -rin | head -n 20 which gives me an output like: 120 bbb 27 ccc 3 aaa ... I would like... (3 Replies)
Discussion started by: ChatPerdu
3 Replies

5. Shell Programming and Scripting

Size of file and directory

Hello. I do have a problem. The statement sounds like this: Given a directory, find all subdirectories (regardless of depth) which contain a file that has more than a half of the size of the respective subdirectory. I've tried to solve this in many ways, but all I came up with is half... (1 Reply)
Discussion started by: WorkOfArt
1 Replies

6. Solaris

Directory size larger than file system size?

Hi, We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB? I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies

7. Shell Programming and Scripting

Can't sort file by size column

Hello, I've done ls -ls >fileout1 When I do the sort command for +4 it sorts it bu group. When I do +5 it sorts it by date. But it's skipping the file size column. Example: rwxr-xr-x 1 Grueben sup 65 16 Sep 13:58 cdee How can I sort it by file size? It doesn't... (2 Replies)
Discussion started by: Grueben
2 Replies

8. 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

9. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

10. Programming

Size of a directory or a file

Hello, Here is my code: :~$ truncate -s 16M MyTestFile.txt :~$ du -h MyTestFile.txt 4,0K MyTestFile.txt Q1: Please why du -h does not work in this case ? Q2: Other than "du -h", how can i get the size of a directory (using linux command) Thanks a lot. Best Regards. (2 Replies)
Discussion started by: chercheur111
2 Replies
RCS(1)							      General Commands Manual							    RCS(1)

NAME
rcs - change RCS file attributes SYNOPSIS
rcs [ options ] file ... DESCRIPTION
Rcs creates new RCS files or changes attributes of existing ones. An RCS file contains multiple revisions of text, an access list, a change log, descriptive text, and some control attributes. For rcs to work, the caller's login name must be on the access list, except if the access list is empty, the caller is the owner of the file or the superuser, or the -i option is present. Files ending in `,v' are RCS files, all others are working files. If a working file is given, rcs tries to find the corresponding RCS file first in directory ./RCS and then in the current directory, as explained in co (1). -i creates and initializes a new RCS file, but does not deposit any revision. If the RCS file has no path prefix, rcs tries to place it first into the subdirectory ./RCS, and then into the current directory. If the RCS file already exists, an error mes- sage is printed. -alogins appends the login names appearing in the comma-separated list logins to the access list of the RCS file. -Aoldfile appends the access list of oldfile to the access list of the RCS file. -e[logins] erases the login names appearing in the comma-separated list logins from the access list of the RCS file. If logins is omitted, the entire access list is erased. -cstring sets the comment leader to string. The comment leader is printed before every log message line generated by the keyword $Log$ during checkout (see co). This is useful for programming languages without multi-line comments. During rcs -i or initial ci, the comment leader is guessed from the suffix of the working file. -l[rev] locks the revision with number rev. If a branch is given, the latest revision on that branch is locked. If rev is omitted, the latest revision on the trunk is locked. Locking prevents overlapping changes. A lock is removed with ci or rcs -u (see below). -u[rev] unlocks the revision with number rev. If a branch is given, the latest revision on that branch is unlocked. If rev is omitted, the latest lock held by the caller is removed. Normally, only the locker of a revision may unlock it. Somebody else unlocking a revision breaks the lock. This causes a mail message to be sent to the original locker. The message contains a commentary solicited from the breaker. The commentary is terminated with a line containing a single `.' or control-D. -L sets locking to strict. Strict locking means that the owner of an RCS file is not exempt from locking for checkin. This option should be used for files that are shared. -U sets locking to non-strict. Non-strict locking means that the owner of a file need not lock a revision for checkin. This option should NOT be used for files that are shared. The default (-L or -U) is determined by your system administrator. -nname[:rev] associates the symbolic name name with the branch or revision rev. Rcs prints an error message if name is already associated with another number. If rev is omitted, the symbolic name is deleted. -Nname[:rev] same as -n, except that it overrides a previous assignment of name. -orange deletes ("outdates") the revisions given by range. A range consisting of a single revision number means that revision. A range consisting of a branch number means the latest revision on that branch. A range of the form rev1-rev2 means revisions rev1 to rev2 on the same branch, -rev means from the beginning of the branch containing rev up to and including rev, and rev- means from revision rev to the end of the branch containing rev. None of the outdated revisions may have branches or locks. -q quiet mode; diagnostics are not printed. -sstate[:rev] sets the state attribute of the revision rev to state. If rev is omitted, the latest revision on the trunk is assumed; If rev is a branch number, the latest revision on that branch is assumed. Any identifier is acceptable for state. A useful set of states is Exp (for experimental), Stab (for stable), and Rel (for released). By default, ci sets the state of a revision to Exp. -t[txtfile] writes descriptive text into the RCS file (deletes the existing text). If txtfile is omitted, rcs prompts the user for text supplied from the std. input, terminated with a line containing a single `.' or control-D. Otherwise, the descriptive text is copied from the file txtfile. If the -i option is present, descriptive text is requested even if -t is not given. The prompt is suppressed if the std. input is not a terminal. DIAGNOSTICS
The RCS file name and the revisions outdated are written to the diagnostic output. The exit status always refers to the last RCS file operated upon, and is 0 if the operation was successful, 1 otherwise. FILES
The caller of the command must have read/write permission for the directory containing the RCS file and read permission for the RCS file itself. Rcs creates a semaphore file in the same directory as the RCS file to prevent simultaneous update. For changes, rcs always cre- ates a new file. On successful completion, rcs deletes the old one and renames the new one. This strategy makes links to RCS files use- less. IDENTIFICATION
Author: Walter F. Tichy, Purdue University, West Lafayette, IN, 47907. Revision Number: 3.1 ; Release Date: 83/04/04 . Copyright (C) 1982 by Walter F. Tichy. SEE ALSO
co (1), ci (1), ident(1), rcsdiff (1), rcsintro (1), rcsmerge (1), rlog (1), rcsfile (5), sccstorcs (8). Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control System," in Proceedings of the 6th International Conference on Software Engineering, IEEE, Tokyo, Sept. 1982. BUGS
Purdue University 6/29/83 RCS(1)
All times are GMT -4. The time now is 12:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy