1

I am running the following command on cygwin

$ find . -printf "%p %m %s \n" | sort -n

and the output is below...

./.metadata/.log 700 17247
./.metadata/.mylyn 700 0
./.metadata/.mylyn/repositories.xml.zip 700 423
./.metadata/.mylyn/tasks.xml.zip 700 250
./.metadata/.plugins/com.google.appengine.eclipse.core/appengine-sdk-proxy.jar 700 8782

(required out format is filename/permission in octal/size in bytes)

I would like to know how to create a similar output on Solaris. (the above command does not work on solaris)

yepeesteve
  • 13
  • 2

4 Answers4

1

You can use Perl to glean the same info as find's -printf:

find . -print | perl -lne '$,=" "; @s=stat $_; print $_, $s[2], $s[7]'
glenn jackman
  • 238,783
  • 38
  • 220
  • 352
  • 1
    In the unlikely event that a filename contains a newline, this will miss that file. No one should be making filenames like that, and lots of other things would probably break too, but it is legal. – evil otto Jun 13 '12 at 19:43
0

There really is no simple way to duplicate this without writing a fair amount of code.

http://www.sunfreeware.com/indexsparc10.html

This is an index to sparc for Solaris 10 - free downloads from sunfreeware. If you are on x86 there is a corresponding download. You want to download and install

findutils-4.4.2-sol10-sparc-local.gz

There are some dependencies that go with it. Otherwise you face writing a good bit of shell, C or perl to duplicate the output.

jim mcnamara
  • 16,005
  • 2
  • 34
  • 51
0

You can get close with -ls:

$ find . -ls | awk '{print $11 " " $3 " " $7 }'

However, that will get you the symbolic permissions, not the octal perms.

evil otto
  • 10,348
  • 25
  • 38
0

This should work on any Unix / Unix like OS, i.e. doesn't requires gnu find, perl or similar:

PATH=`getconf PATH`
LC_ALL=C find . -exec ls -dils {} + | awk '
function parse(s,level)
{
    p=0;
    r=substr(s, 1 ,1)
    w=substr(s, 2 ,1)
    x=substr(s, 3 ,1)
    if(r=="r") p+=4;
    if(w=="w") p+=2;
    if(x=="x") p+=1;
    if(x!="-" && x!="x") { p+=1; xtra+=level }
    return(p)
}
function s2n(s)
{
    xtra=0
    owner=parse(substr(s, 2 , 3), 4)
    group=parse(substr(s, 5 , 3), 2)
    other=parse(substr(s, 8 , 3), 1)
    return(0+(xtra*1000)+(owner*100)+(group*10)+other);
}
{
    perm=s2n($3);
    size=$7
    $1=$2=$3=$4=$5=$6=$7=$8=$9=$10=""
    sub("^ *","")
    print $0 " " perm " " size
}'
jlliagre
  • 29,783
  • 6
  • 61
  • 72
  • `find` on Solaris may not have the `+` terminator for the `-exec` option. – glenn jackman Jun 12 '12 at 22:25
  • @glenn jackman : Actually not. While undocumented until Solaris 9, this + terminator has been available since the first Solaris 2 release a couple of decades ago. – jlliagre Jun 12 '12 at 23:20