Sponsored Content
Full Discussion: Sorting ls by filesize
Top Forums UNIX for Dummies Questions & Answers Sorting ls by filesize Post 22495 by peter.herlihy on Tuesday 4th of June 2002 06:28:58 PM
Old 06-04-2002
Sorting ls by filesize

I saw some stuff in the search results on this - but nothing specific.....

I have a significant number of files (c. 300) which are output from a large process that I run. These are compared with a 'baselined' set of files - so I can quickly see if there are differences based on the sizes of the files.

I want to sort the directory into filesize...and not by number of lines. I need byte size to confirm differences.

I've thought about awk, wc -c, I've looked at sort -n ....and I've looked at the ls options...but I cant seem to get a combination to work for me.

ideas? And Yeah I realise I could cut the filesize from the ls and sort by that....but there must be a simpler way....

(Oh and I work with SunOS 5.6 and typically use a bash shell).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

filesize

I know in php if you use the function filesize it will return the size of the file in bytes, but is there an easy way to get the size in MB. Cheers (2 Replies)
Discussion started by: jmg5
2 Replies

2. Shell Programming and Scripting

FileSize ???

How do I identify if there is any content in a file? If there is nothing in a specified file, I'd like to send an email indicating that there is nothing to report. Any help appreciated. (3 Replies)
Discussion started by: Cameron
3 Replies

3. Shell Programming and Scripting

How to truncate as filesize?

Hello everybody it's me again. I have a procces that is writing in a 'file1' automatically but i want to truncate 'file1' to a filesize 'x' that mean if the 'file1' size is 'x' i want to delete the first lines while the last lines are being writed, that have sence? in the process are an... (1 Reply)
Discussion started by: Lestat
1 Replies

4. HP-UX

Increasing Filesize on HP-UX UNIX

Dear sir My hp-ux OS version is 11i (11.23) , and Oracle DB is 9i (9.2.0.6) the problem that I can't create any file (DB datafile , export Dump file , Rman backup pices.... etc) under the OS biger than 2 GB and the csh % limit check is %limit cputime unlimited filesize ... (4 Replies)
Discussion started by: ae_nassar
4 Replies

5. UNIX for Dummies Questions & Answers

UNIX and filesize

Hey guys. What I need to do is this: I need to find files that have a certain filesize (for this case a file size of 0 (zero) ) When I find this file with a filesize of zero I need to echo a statement that tells the user to delete it and not to delete it if the filesize is greater than... (3 Replies)
Discussion started by: ndoggy020
3 Replies

6. Shell Programming and Scripting

filesize

I want to know if there is any unix command to view the size of the file? eg. i have a directory letter in this i have file a,b,c,d,e. i just want to know the size of file d and not any other. (3 Replies)
Discussion started by: infyanurag
3 Replies

7. Shell Programming and Scripting

getting filesize

Hello, I have a script that should store file size in a variable $filesize. I don't know what is the best way to do it. I tried ls -lt myfile.txt | sed something >$filesize but I don't know how to use sed to get filesize. I know that the owner of the file is root and then we have some... (6 Replies)
Discussion started by: pppswing
6 Replies

8. Shell Programming and Scripting

Filesize not working

I am having problems with finding the filesize with this in my script: filesize=`ls -l | awk '$5=0'` if ; then ls -l | awk '{print $9 " " $5}' if ; then echo "Would you like to delete this file? (y/n)" if yes do this elif no do this fi fi else... (7 Replies)
Discussion started by: akeenabawa
7 Replies

9. Solaris

Check for filesize limit

How do I check for any file size limitations in a directories ? I remember my administrator had set a file limitation for a certain directory. I would like to know how I can check that. Thank you. (2 Replies)
Discussion started by: Leion
2 Replies

10. Shell Programming and Scripting

if condition for filesize

Hi, I want to check file size in unix, based on file size I am going to execute appropriate command. I tried below, but getting the error. System details – Machine hardware: sun4u OS version: 5.9 if ( -s $f1 ) then echo "filename exists and is > 0 bytes" else echo "filename... (7 Replies)
Discussion started by: rahulbahulekar
7 Replies
CG(1)																	     CG(1)

NAME
cg - Recursively grep for a pattern and store it. SYNOPSIS
cg [ -l ] | [ [ -i ] pattern [ files ] ] DESCRIPTION
cg does a search though text files (usually source code) recursively for a pattern, storing matches and displaying the output in a human- readable fashion. It is intended to give some of the functionaly of AT&T's cscope(1) tool, with the advantages of simplicity and not being language-specific. The script will colorize output if configured as such. It is typically run with a Perl regular expression to search for. The search can be made case insensitive by using the -i option. A list of files may also be specified with an additional argument after the pattern. Put the files pattern in quotes to make it be matched by Perl rather than by the shell. Running the script with no arguments will recall the results of the previous search. After the search, entries found can be edited using the vg(1) script. The -l option shows the last log made. SOME EXAMPLES
cg - alone recalls the previous search results. cg -i pattern - search the default list of files for all files matching the pattern (and case-insensitively). cg pattern '*.c' - search recursively for pattern in all *.c files. This automatically converts '*' to '.*' and '.' to '.' for you and does a Perl pattern match on all files in the tree. cg pattern *.c - search through the shell-expanded list of *.c files, so not done recursively (in other words, only the files your shell pass to the script as arguments). cg -l - show the last log made. COMMAND-LINE OPTIONS -i Do a case-insensitive search. -l Show the last log made. -p Toggle the default pager option. cg has a bulit-in pager function, which can be enabled or disabled by default (in .cgvgrc). If the default is enabled, this option disables the pager; if the default is disabled, this option enables it. -P Force the built-in pager to be disabled. FILES
${HOME}/.cglast Log file of the last search. ${HOME}/.cgvgrc Per-user configuration file (if the defaults are not desireable). ${HOME}/.cgvg/* Log files in $HOSTNAME.shell_pid form with the log of the last search. SEE ALSO
vg(1), perl(1), find(1), grep(1), cscope(1) AUTHOR
cg was written by Joshua Uziel <uzi@uzix.org>. 13 Mar 2002 CG(1)
All times are GMT -4. The time now is 08:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy