ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i need a way to find the size of any file... you'd think this would by easy with a cut command... something similar to the following (the following is with ubuntu):
by the above it would appear that that cut command gives you the proper response, but it doesn't work for all files or all file sizes, and seems to depend on the formatting of the ls command for different types of UNIX (the following is with solaris):
in both of the above examples, the size is the 5th column, but because of extra spacing between the columns, the cut commands produce different results... i need a command that will find the file size regardless of the UNIX box it is on, and what convention it uses for the ls command.... so i need a better way to use the cut command, or i need a different way to access the file size altogether
Well ... the beauty of awk is that it will take ANY amount of ANY whitespace (spaces, tabs, ... not NewLines ;})
as a field separator by default ... you could use sed instead, too, but that would be quite lengthy.
The following may be redundant since it still uses awk, but is another way to get file-size info.
Does your Solaris box have the stat command with the -t (terse) option? It give output like this (the first 2 fields are the relevant ones, file name and size):
yeah the box has that command... could do it that way i suppose... either way it works though, which is great... that will teach me for developing something on ubuntu and implementing on solaris, lol
yeah the box has that command... could do it that way i suppose... either way it works though, which is great... that will teach me for developing something on ubuntu and implementing on solaris, lol
You would have hit that snag irrespective of the OS you work
on... to throw "cut" off all it takes is files w/ different owners/
groups since it goes by single characters as delimiters, and
the padding WILL vary.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.