Unix/Linux Go Back    


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

How to list file size on HPUX?

HP-UX


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-28-2013
tbochan tbochan is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 28 June 2013, 1:35 PM EDT
Posts: 3
Thanks: 0
Thanked 3 Times in 1 Post
How to list file size on HPUX?

I used to use ls -l cut to detrmine file size, and google searches didn't come up with anything else but 'stat' which doesn't appear on HPUX.
I discovered the humble 'wc -c' which does this job very neatly, and thought I would share it.
Sponsored Links
    #2  
Old Unix and Linux 06-28-2013
rbatte1 rbatte1 is offline Forum Staff  
Moderator
 
Join Date: Jun 2007
Last Activity: 14 April 2015, 5:23 AM EDT
Location: Lancashire, UK
Posts: 2,179
Thanks: 713
Thanked 391 Times in 348 Posts
Would you consider:-
Code:
ls -l file|read perms links owner group size rest
echo $size

This may run faster for larger files as ls reads the directory, where wc will actually read the whole file.



I hope that this helps.
Robin
Sponsored Links
    #3  
Old Unix and Linux 06-28-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 17 April 2015, 5:55 PM EDT
Location: Saskatchewan
Posts: 20,487
Thanks: 875
Thanked 3,606 Times in 3,370 Posts
Quote:
Originally Posted by rbatte1 View Post
This may run faster for larger files as ls reads the directory, where wc will actually read the whole file.
This is implementation-dependent, many will not.
    #4  
Old Unix and Linux 06-28-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 9 April 2015, 6:09 PM EDT
Location: Galactic Empire
Posts: 3,402
Thanks: 240
Thanked 1,216 Times in 1,142 Posts
Perl can be used to invoke stat system call. Refer post
Sponsored Links
    #5  
Old Unix and Linux 06-28-2013
tbochan tbochan is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 28 June 2013, 1:35 PM EDT
Posts: 3
Thanks: 0
Thanked 3 Times in 1 Post
Yes, that's actually the syntax I use. I had been sort of miffed for so long that there wasn't a simple alternative, the discovery of "wc -c" was a bit of a shock.
I'm not sure that "wc -c" will scan the file if it doesn't need to. I guess an experiment will sort that out.
Thanks for the response
Sponsored Links
    #6  
Old Unix and Linux 06-28-2013
rbatte1 rbatte1 is offline Forum Staff  
Moderator
 
Join Date: Jun 2007
Last Activity: 14 April 2015, 5:23 AM EDT
Location: Lancashire, UK
Posts: 2,179
Thanks: 713
Thanked 391 Times in 348 Posts
I suppose I may well be err-ing on the caution side from normally using wc -l and counting lines, rather than characters. I know that can take a long time, so I just assumed.

I suppose that to assume makes an ass from u and me.



Robin
Sponsored Links
    #7  
Old Unix and Linux 06-28-2013
tbochan tbochan is offline
Registered User
 
Join Date: Jun 2013
Last Activity: 28 June 2013, 1:35 PM EDT
Posts: 3
Thanks: 0
Thanked 3 Times in 1 Post
I just did a test (on HPUX) and "wc -c" does read the whole file. Shame.
I'll keep using Robins syntax :
ls -l | read _ _ _ _ filesize _
The Following 3 Users Say Thank You to tbochan For This Useful Post:
Corona688 (06-28-2013), MadeInGermany (06-29-2013), rbatte1 (06-28-2013)
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
List of file name with size Jewel HP-UX 7 11-21-2012 04:42 AM
How to list a file size, but not its name? ordano UNIX for Dummies Questions & Answers 2 02-12-2009 01:00 AM
command to list file size rgordon HP-UX 3 12-05-2007 04:43 AM
List File size komputersman UNIX for Dummies Questions & Answers 10 06-13-2007 04:39 PM



All times are GMT -4. The time now is 06:55 PM.