How to list file size on HPUX? | Unix Linux Forums | HP-UX

  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 Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 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 06-28-2013
rbatte1 rbatte1 is offline Forum Advisor  
Registered User
 
Join Date: Jun 2007
Last Activity: 24 April 2014, 12:58 PM EDT
Location: North-West UK
Posts: 1,255
Thanks: 376
Thanked 203 Times in 186 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 06-28-2013
Corona688 Corona688 is online now Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 24 April 2014, 3:10 PM EDT
Location: Saskatchewan
Posts: 18,539
Thanks: 682
Thanked 3,036 Times in 2,856 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 06-28-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 24 April 2014, 12:13 PM EDT
Location: Galactic Empire
Posts: 3,284
Thanks: 227
Thanked 1,158 Times in 1,095 Posts
Perl can be used to invoke stat system call. Refer post
Sponsored Links
    #5  
Old 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 06-28-2013
rbatte1 rbatte1 is offline Forum Advisor  
Registered User
 
Join Date: Jun 2007
Last Activity: 24 April 2014, 12:58 PM EDT
Location: North-West UK
Posts: 1,255
Thanks: 376
Thanked 203 Times in 186 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 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 Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 03:11 PM.