in bash, I want to use find to locate only files that ends with .sh. Then for each .sh…
- User
in bash, I want to use find to locate only files that ends with .sh. Then for each .sh file, I want to do a fgrep inside the file to find lines containing the text SRC
- Assistant
To locate only files that end with .sh, you can use the following command:
find /path/to/search -name "*.sh"This command will search the specified directory and all its subdirectories for files whose names end with .sh. Once you have located the files you want to process, you can use the
fgrepcommand to search for lines containing the text "SRC". Here's an example command that will search the specified files for lines that contain "SRC":find /path/to/search -name "*.sh" -exec grep -l "SRC" {} \;This command will search the specified files using
find, and then usegrep -lto list the lines containing "SRC" in each file. The{}represents the file name, and the\;at the end of the command specifies that the command should be executed for each file found byfind.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.