Hello all,
I am fairly new to the freebsd environment in terms of shell scripting. Most of my experience is with hosting and server solutions on freebsd.
I am currently trying to write a shell script that will do the following.
1. find all index.php and index.html files. and place those values into a variable called $found_files.
2. cat those files, and search for the keyword "iframe"
3. Only print those results that it finds the keywords to the screen with the line number and path to the file it finds.
The issue I am having is getting the output to print the directory location of the file it finds.
Here is my script.
If any one can shed some light on this I would be very appreciative.
I am fairly new to the freebsd environment in terms of shell scripting. Most of my experience is with hosting and server solutions on freebsd.
I am currently trying to write a shell script that will do the following.
1. find all index.php and index.html files. and place those values into a variable called $found_files.
2. cat those files, and search for the keyword "iframe"
3. Only print those results that it finds the keywords to the screen with the line number and path to the file it finds.
The issue I am having is getting the output to print the directory location of the file it finds.
Here is my script.
Code:
#!/bin/tcsh
foreach found_file ( `find . -type f \( -name "index.html" -o -name "index.php" \)`)
echo $found_file | xargs cat | grep -nH '<iframe'
end
If any one can shed some light on this I would be very appreciative.