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