1753418 Members
4851 Online
108793 Solutions
New Discussion юеВ

Re: ls alignment

 
ertraccia
Occasional Advisor

ls alignment

Hi everyone,

I have a problem with ls command; when I run it I get an output like the next one:

-rwxr-x--- 1 root CR-USER 48 Feb 26 11:14 ControllaQIO
-rwxr-x--- 1 root root 2630207229 Feb 26 10:36 FileProve.txt
-rwxr-x--- 1 root CR-USER 229 Feb 26 11:47 LancioTest512Mb
-rwxr-x--- 1 root CR-USER 509 Feb 26 12:06 LancioTestParalleloAPC2

I didn't find anything on the man page....is there a way to have a correct output?

Thanks in advance
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor

Re: ls alignment

Hi:

The output is correct. What matters is that there are discrete _fields_ separated by whitespace. Hence, you can parse based on the field-number with "cut' or "awk' or Perl.

If you want to reformat the output, pipe the output to a tiny 'awk' script that uses a 'printf' statement.

Regards!

...JRF...
V. Nyga
Honored Contributor

Re: ls alignment

Hi,

check with 'alias' if there's an alias command for 'ls'.
That would explain such a result.
Then you have to change that setting.
Maybe you get also a correct output with '/usr/bin/ls'?

What does 'which ls' says?

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
Steven Schweda
Honored Contributor

Re: ls alignment

> [...] is there a way to have a correct
> output?

Define "correct".

Write your own "ls"?

Use GNU "ls", which has more (possibly
useful) formatting options?

http://www.gnu.org/software/coreutils/
http://www.gnu.org/software/coreutils/manual/
MarkSyder
Honored Contributor

Re: ls alignment

Judging from the thread title, your complaint refers to the size field that is very large and therefore out of alignment.

You could write a script that takes the fields from ls and uses awk to align them.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
ertraccia
Occasional Advisor

Re: ls alignment

I used work with Tru64 and when I say correct I mean that ls give an output with correct alignment without options.

Actualy the only alias defined is:
ls=/usr/bin/ls (the default one)

I noticed that it do this only when the file size is bigger then 10Mb
V. Nyga
Honored Contributor

Re: ls alignment

>I noticed that it do this only when the file size is bigger then 10Mb

Yes, that's right, but why do you complain about that? Because you're more familiar with Tru64?
Well, ok - this is HP-UX ... I never had problems with this.
This *is correct* for HP-UX.

BTW you only see this with the 'll' or 'ls -l' command :-)

Volkmar
*** Say 'Thanks' with Kudos ***
ertraccia
Occasional Advisor

Re: ls alignment

If it was for me....it would be fine....but this is what Customer asked me (after using Tru64 for lots of years)

Anyway, I think that awk solution should be ok, for now.

Thanks to everyone ;-)
ertraccia
Occasional Advisor

Re: ls alignment

See above