Seems simple but I am having difficulty with this one: I am trying to write a single command line argument (which will be a path) - the program should print out the owner of the path.
I can not get anything I write to run.
Please help.
Sorry, could you please be more descriptive.
To find the owner of the path. -- path could either be a file or a directory.
Did you mean finding the owner of the file or a directory ?
Yes, find owner of file or directory to print that information out once the script is run. I know the command to get the information, I am having difficulty writing the command within a script for a user to supply a file/directory to get that information.
#! /bin/zsh
if [ $# -eq 0 ]
then
echo "USAGE: script file/directory"
exit 1
fi
if [ -f $1 ]
then
echo "Owner of $1 : `ls -l $1 | awk '{ print $3 }'`"
else
echo "Owner of $1 : `ls -ld $1 | awk '{ print $3 }'`"
fi
exit 0
Does it matter if it is for the C Shell?
if you have GNU find
find /path -printf "File:%f - Owner:%u\n"