Subject: Re: ls with full path?
To: Brian <bmcewen@comcast.net>
From: David <david@inducedreality.net>
List: port-cobalt
Date: 03/08/2004 21:06:14
On Mon, 8 Mar 2004, Brian wrote:
> I'm trying to find a command that will output each file with the full
> path to the file prepended (as could be useful for scripting); but
> don't see an option for ls that will do it,  nor am I finding something
> when I look around via man -k.
>

The best I know of is find.  For example, FreeBSD includes in its daily
security run this bit:

case "$daily_status_security_chksetuid_enable" in
    [Yy][Ee][Ss])
        echo ""
        echo 'Checking setuid files and devices:'
        # XXX Note that there is the possibility of overrunning the args
to ls
        MP=`mount -t ufs | grep -v " nosuid" | awk '{ print $3 }' | sort`
        if [ -n "${MP}" ]
        then
            set ${MP}
            while [ $# -ge 1 ]; do
                mount=$1
                shift
                find $mount -xdev -type f \
                        \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
                        \( -perm -u+s -or -perm -g+s \) -print0
            done | xargs -0 -n 20 ls -liTd | sed 's/^ *//' | sort -k 11 |
              check_diff setuid - "${host} setuid diffs:"
            rc=$?
        fi;;
    *)  rc=0;;
esac


You can simplify this quite a bit for a single run, though.  The following
will find all executable files on your machine:

find / \( -perm -u+x -or -perm -g+x -or -perm -o+x \)

David