Question: For this project, you will work with the bash commands such as find, file, and grep to locate all of the images within a specific
For this project, you will work with the bash commands such as find, file, and grep to locate all of the images within a specific directory (including subdirectories), regardless of file extension. There are many other options that you could use for this project as well, including locate, slocate, or xargs. There are many different strategies that could be used to accomplish this project's requirements.
The demonstrated commands from the beginning of the lab are: find . -name '*' -exec file {} \; | grep -i -o -E '^.+: \w+ image' - for grep using extended regex
find . -name '*' -exec file {} \; | grep -i -o -P '^.+: \w+ image' - for grep using PCRE regex
You can also improve the processing and memory requirements of this command by using the -type option for find instead of -name or -iname. find . -type f -exec file {} \; | grep -i -o -E '^.+: \w+ image'
As a reminder, there are more image types than just the JPG, GIF, and PNG that are identified with this command. You need to identify ALL image types. This means that the commands included above are not completely sufficient to identify all images in a system.
Your script should take a path as an input parameter. This will allow your script to be located anywhere on a system, but still search a directory for images. If no path is provided, then the current directory should be searched. As a general design rule, do NOT hard code the directory path that will be searched. You should also include a --h or --help option to show how the script accepts input and any usage guidelines for the user. Given that directory, you should identify ALL images. From there, you will need to identify the image name, image type, file owner, the full path, and hashes (MD5 and SHA1) of each image.
The provided directory included images with the extension changed to .doc .pdf and etc. in addition to .jpg
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
