find
Regina wants to search for and delete all files in /home/regina/data/ that have a .odt extention. Her computer system is a modern RHEL system. What find command would she use? How would the command change if the were to do the same search in /etc/docs/, a directory to which she does not have write access (Regina is part of the sudoers group)?
To search for and delete all files in /home/regina/data/ that have a .odt extension using the find
command, Regina can use the following command:
find /home/regina/data/ -type f -name '*.odt' -delete
This command will find all files with the extension .odt
in the directory /home/regina/data/
and delete them.
If Regina wants to search for and delete all files with a .odt extension in /etc/docs/, a directory to which she does not have write access, she will need to use sudo
to gain the necessary permissions. The command she can use is:
sudo find /etc/docs/ -type f -name '*.odt' -delete
This command will find all files with the extension .odt
in the directory /etc/docs/
and delete them, provided that Regina has sufficient privileges as a member of the sudoers group.