Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 153120 - ls output needs more control and is too limited
Summary: ls output needs more control and is too limited
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-04-01 18:12 UTC by Brian "netdragon" Bober
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-04-01 18:56:40 UTC


Attachments (Terms of Use)

Description Brian "netdragon" Bober 2005-04-01 18:12:08 UTC
Description of problem:

I would like to propose and additional parameter for ls that would give a lot
more control. The parameter would be --printf (like in printf find) or something
like that, and would let you specify what columns you want to see.

There are issues with the parameters for ls. The main issue is that you cannot
properly individually specify which columns of ls -l you need, which means you
have to use some regexp magic with a stream editor, which is not very efficient
and hard to remember how to do. It's also not good for people migrating from
other platforms. There are a huge mess of hard-to-remember modifiers

To give an example of the mess:
ls -l shows:
drwxr-xr-x  22 root root     4096 Apr  1 02:23 var

To remove the user name, ls -g:
drwxr-xr-x  22 root     4096 Apr  1 02:23 var

To remove both user and group ls -gG
drwxr-xr-x  22     4096 Apr  1 02:23 var

Big issues:
1) We can't (afaik) remove time from the -l listing.
2) We can't (afaik) individually show file size, since the -s parameter shows
disk space usage and doesn't even match the file size which is shown in -l (if
you use --block-size=1)
3) We have to use the find `pwd` in order to show the full file path, because ls
doesn't allow you to show bare output with full pathnames. Instead, it prints
the directory name, then the files that are contained.

First of all, we need a replacement for -s that shows the actual size of file,
not disk space used. Perhaps --actualsize, and we need a parameter to remove any
field from -l (or better yet, specify fields)

But we need also a parameter to give us more control on placement...

I suggest we have a --printf parameter that you use formatting characters, such
as (but not necessarily) %%%f to show the filename only, %%%[n.m]b to show the
full path of the file, %%%[n.m]c to show the files' path relative to the current
directory. n and m would be optional and would tell how many portions of the
path to remove from the beginning and end of the output (0 for either does
nothing) %%%t for time, %%%u for user, %%%s for actual size, and %%%y for number
of blocks used on disk (like -s), etc... It'd look like:
user@server ~ ls --printf "%%%c %%%1.c %%%2.b %%%1.b %%%b %%%.1b %%%f %%%s fdsa
fdsa %%%u" \ blah/foo.txt

./blah/foo.txt blah/foo.txt user/blah/foo.txt home/user/foo.txt
/home/user/foo.txt /home/user foo.txt 543 fdsa fdsa user

I chose %%% simply because it wouldn't confuse people over other definitions for
printf

Comment 1 Brian "netdragon" Bober 2005-04-01 18:56:40 UTC
Forget the printf parameter because find has it (though it'd be nice to have
more control over stipping directories) -- I'll file a new bug about ls needing
a proper -s parameter.


Note You need to log in before you can comment on or make changes to this bug.