Greetings,
I need to find few patterns related to password (pwsd, pwd, password etc) in a directory includig sub -directories.
I need to redirect the output of find (in combination with grep) to a file which will be later used to verify the files.
OS is Sun Solaris 5.10.
The out put file format needs tp be as below-
//
-------------------------------------------------------------------------
File name = <Absolute Path of the file >
Pattern Matching Line Number =<Line number>
Pattern matching Line =<Line>
-------------------------------------------------------------------------
File name = <Absolute Path of the file >
Pattern Matching Line Number =<Line number>
Pattern matching Line =<Line>
-------------------------------------------------------------------------
//
I am using below command . However I am not sure how do i format the output. Appreciate your expert advice/suggestions.
Code-
#!/bin/ksh
find_matches()
{
DIR=$1;
FILE=$2;
find ${DIR}/. \( -name "*proper*" -o -name "*.txt" -o -name "*.csv" \) -n -exec grep -i pwd {} \; -print >> ${FILE}
find ${DIR}/. \( -name "*proper*" -o -name "*.txt" -o -name "*.csv" \) -n -exec grep -i password {} \; -print >> ${FILE}
find ${DIR}/. \( -name "*proper*" -o -name "*.txt" -o -name "*.csv" \) -n -exec grep -i pswd {} \; -print >> ${FILE}
}
find_matches ${DIR1} ${tmp_file}
find_matches ${DIR2} ${tmp_file}