I'm a linux newbie, so pardon me if you don't understand me :)
I have a problem that I need to run a command chmod 777 XXX
(XXX is directory) but I cant login to it, but I can push UNIX script which will be executed to do this. But the problem is that I don't know in which path this script is started/placed :).
IN DETAIL: I need script which will check if relative path (directory tree) CCCC/YYY/XXX
exists on this machine somewhere and if it exists following command needs to be started on this directory chmod 777 XXX
. (XXX should be resolved to absolute path :))
I did some test with find, but no real result.
The locate
command will help you here:
path_part=CCCC/YYY/XXX
if output=$( locate "$path_part" 2>/dev/null ); then
grep "$path_part$" <<< "$output" |
while IFS= read -r dir; do
# do something in "$dir"
done
fi
locate
requires you to run updatedb
-- your system may run it already periodically.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.