Home » Questions » Computers [ Ask a new question ]

Script in UNIX (Bash) to determine if the user is the owner of a file

Script in UNIX (Bash) to determine if the user is the owner of a file

Something that would take any number of arguments, where each argument would be a path to a file or directory. If the user does own a particular path then it should check it to see if the path represents a normal file AND if that file is executable. If it is, then your script should execute/run the file.

Asked by: Guest | Views: 62
Total answers/comments: 1
Guest [Entry]

"To get current user id you do:

id -u

to get owner of file, you do:

stat -c ""%u"" file.name

to test if one value is the same as the other you do:

if [ ""$first"" -eq ""$second"" ]
then
....
fi"