Register | Login

Find command's output can be substituted to another command.


 


Consider a scenario that you want to search for all log files in /tmp directory. Also want to see which log has SQL exception.


 


find /tmp -name "*.log" -exec grep -l "SQL" {} ;


 


the above command will search for all log files and if the file exist then it will execute grep -l "SQL" on that file and check whether that SQL word is available in the log file.


{} - is the place where the find output will be substituted


Note: the default output will only give the filename as output


 


The beginners first need to learn about find commands basic options. This can be learned from http://www.yourwiz.com/linux/find-command-useful-options/ .



Who Voted for this Article



YourWiz.com, is a website that will allow everyone to share their knowledge, tip or information through community micro blogging.