Search contents of files within specified directory I aim to search the contents of files at a specified directory.

take an example in spotlight search

'Marked important question' in dir('/desktop)


How can such a task be accomplished?
From the Finder

An easy way is to open a Finder Window to the folder of interest, and use the search box in the upper right corner. For this to work effectively, Finder Preferences should be adjusted as follows:

Under Finder/Preferences/Advanced tab, change 

When performing a search: to

"Search the Current Folder"

From the Command Line

Use mdfind, with the -onlyin option, as below, which will search the current directory for all files with a .jpg suffix:

mdfind -name .jpg -onlyin .