In: Computer Science
Write a brief explanation of why these commands function as described. 8. Why does `find . -name '*.pdf'` not find "BOOK.PDF" even if that file is in the current working directory? 9. Why does `find . -name 'pdf*'` not find "book.pdf" even if that file is in the current working directory? 10. Why does `find /etc -iname '*conf*'` return both directories and files?
`find . -name '*.pdf'`
The above command lists all the file in the current working directory that has the file extension .pdf. And -name switch is case sensitive. There the above command does not find 'BOOK.PDF' even if it is in the same working directory.
`find . -name 'pdf*'`
The above command searches for files that start with pdf in their name. We have used a wild card character * in the end of the search pattern. Example of files that will be listed are pdf1.txt, pdffile.jpg, etc. It does not find book.pdf because the file doesn't begin with the text 'pdf'. Also remember -name switch is case sensitive.
find /etc -iname '*conf*'
In the above command we have used wild card characters * in the beginning and end of the search text. And the -iname switch is a case insensitive search switch. So the above command returns all the file and folders that have conf as part of their name irrespective of whether it is a file or directory.