Question: I've just made a very basic shell script which takes a input path and displays the attributes of the files in that path. 

Problem: the script is running on my PC, but when I try to run it on my college UNIX server I'm getting an error: 

```
find: bad option -printf
             find: path-list predicate-list

```

* My PC: Ubuntu
* My college server: SunOS nyx 5.9 Generic\_118558-11 sun4u sparc SUNW,Sun-Fire-V210

The code:

```
#!/bin/bash

echo " enter address in form : /home/rohan/../.."
read ARG

if [ -n "$ARG" ]; then
echo "input path taken : $ARG"    
# ls -lsh $ARG"/"*.txt 

else
     ARG=$(pwd)
fi

echo " enter option "
echo " 1. file size, 2. permission, 3. owner/group, 4. all , 5. exit" 
read OPTION

while [ $OPTION != "5" ]
do

  if [ $OPTION = "1" ]; then
  find $ARG"/"*.txt  -printf " %p     %s bytes   \n"

 elif [ $OPTION = "2" ]; then
 find $ARG"/"*.txt  -printf " %p     %M    \n" 

 elif [ $OPTION = "3" ]; then 
 find $ARG"/"*.txt  -printf " %p     %g    \n" 

 elif [ $OPTION = "4" ]; then 
 find $ARG"/"*.txt  -printf "%p      %s bytes    %M     %g    \n"

   fi

  echo "enter option again"
  echo " 1. file size, 2. permission, 3. owner/group, 4. all , 5. exit" 
  read OPTION
 done

```

Answer: 
You have two problems on Solaris -printf and your general syntax, 

try:

```
find $ARGS -name '*.txt' -exec ls -l {} \; | nawk '{print $5, $(NR) }'

```

Where ARGS is a directory not a filename. Use -name. Next printf - you will have to use something like what I gave you - pipe ls -l for each file into nawk - NOT awk on Solaris - and print the fields you want. bytes are field #5, so `'{print $5}'` works for that. the last field `$(NR)` is the filename

awk on solaris is a very very old implementation and you cannot port unbuntu GNU awk syntax and generally have it work the way you want on solaris awk.
An alternative to `find -printf` is to use `stat --printf` on a set of files to print useful info about them. This is a code snippet that factors out calls to `find` and uses shell glob to match the set of files:

```
# ...

usage() {
   echo "enter option again"
   # ...
}

# read options
while read OPTION; do
    format=""
    case $OPTION in
        1) format="%n    %s bytes\n" ;;
        2) format="%n    %A\n" ;;
        3) format="%n    %U/%G\n" ;;
        4) format="%n    %s bytes  %A  %U/%G\n" ;;
        5) exit ;;
        *) usage ;;
    esac

    # print file info 
    shopt -s nullglob
    for file in "$ARG"/*.txt; do
        stat --printf "$format" "$file"
    done
done

```