Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
Is there a way to get the "ls -l" command to align its columns (e.g. force a fixed size) when the command is executed individually for each file to be listed (e.g. in a script loop or such)? Right now, I get ragged/jagged columns because "ls -l" is trying to make each listing compact horizontally. But as file sizes, and lengths of owner names, and such vary, the overall length of each output instance varies, making the columns ragged.
Or something like that??
EDIT
sorry im an idiot, of course that wont work X|
EDIT
Why dont you open up vi, or a text editor, and run the command from their? that way you can scroll to the sides
Or something like that??
EDIT
sorry im an idiot, of course that wont work X|
EDIT
Why dont you open up vi, or a text editor, and run the command from their? that way you can scroll to the sides
The command is being run from inside a script, once per file, as the script processes files.
Quote:
Originally Posted by jsteel
Is an "ls -1" (that's a "one") which will list everything in one column a solution? Or do you need the other information that is provided by "ls -l"?
I need the other information, which is why I'm doing "ls -l" (actually, "ls -dGil" for the script I'm editing on today, but there are others).
Quote:
Originally Posted by Reuti
You could use the output of ls -lh by printf to reformat it:
(adjust to your needs). I would use awk to process the output of ls -l, as then it's known to be $1..$8.
That might work. I'll give both ways a try. As long as the format "ls -l" uses stays constant, then $1..$8 or whatever should be consistent. Someone on IRC also suggested formatting with the find command and -printf.
The ultimate solution when listing one file at a time, is to use "find" with fixed -printf formatting, instead of "ls". It is more complex, but more powerful. This is more useful in a script than as a manually typed command. Be sure to use "-maxdepth 0" if what you list could include directories and you don't want the while directory tree to be recursed through.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.