

What's it
=========

This patch is against fileutils 4.1. If you haven't got this package,
you should download one at 
http://ftp.gnu.org/gnu/fileutils/fileutils-4.1.tar.gz

With this patch, ls(1) can list files according to file types or access
permittions, such as directories, symbolic links, fifo files, etc. 
There's no side effect on the other ls(1) options. And it is easier to use
than uniting with pipe programs.


Install
=======

Unpack the fileutils-4.1.tar.gz source tarball:

xuming:~/tmp$ ls
fileutils-4.1.tgz  ls-4.1.0.patch
xuming:~/tmp$ tar zxf fileutils-4.1.tgz
xuming:~/tmp$ ls
fileutils-4.1/  fileutils-4.1.tgz  ls-4.1.0.patch

Then patch it:

xuming:~/tmp$ patch -p0 < ls-4.1.0.patch
patching file fileutils-4.1/ChangeLog
patching file fileutils-4.1/man/ls.1
patching file fileutils-4.1/src/ls.c

That's it. Now you can get into the fileutils directory and do anything
as usual:

./configure
make

You can also just compile the ls file:

./configure
cd lib
make
cd ../src
make ls
su root
cp ls /bin
cp ../man/ls.1 /usr/man/man1


Usage
=====

The patch appends an option, -y or --by-type, into the ls. Try --help:

...
  -X                         sort alphabetically by entry extension
  -y, --by-type=TYPE         list files by types or permissions:
                               socket,symbol,regular,block,dir,char,fifo,
                               setuid,setgid,sticky,
                               [ugoa...][[+-=][rwxXstugo...]...][,...]
  -1                         list one file per line
...

Each entry in this TYPE list, socket,symbol,regular,block,dir,char,..., 
reflects to:

socket:  socket file
symbol:  symbolic link
regular: regular file
block:   block device
dir:     directory
char:    character device
fifo:    fifo
setuid:  if the UID bit was set
setgid:  if the GID bit was set
sticky:  if the sticky bit was set

Very simple and direct, huh? 

The idea of '[ugoa...][[+-=][rwxXstugo...]...][,...]' is from GNU chmod(1). 
You can read its man page for details. However, I personally prefer to 
numbers like 644, 4755, etc., instead.


Examples
========

ls -y dir                     list directories
ls -y socket                  list socket files
ls -y 755                     list excutable files

The '-y' option can be specified more than once in a command line.

ls -y setuid -y setgid        list files were set-UIDed or set-GIDed
ls -y socket -y fifo          list socket files or fifo files

This patch doesn't affect other options. So you can:

ls -lF --color=auto -y dir    list directories with color and long format

Notice that '-y setuid' and '-y 4755' behave differently. Any set-UIDed
files will be listed by 'ls -y setuid'. But 'ls -y 4755' only lists
set-UIDed files WITH the 755 permittion.


Contact me
==========

If you have any opinions or recommends, please do not hesitated to 
reach me at <xuming@users.sourceforge.net>. If you live in China mainland, 
try to <xuming@shdv.com> instead for the you-know-what reason.



