I am writing a script to read multiple log files and find lines with a specific string. However I am getting an error when trying to egrep/grep on the file.
I have a file that has the names of the log files to read (see below)
files.txt
./code_a.log ./code_b.log log_analysis.ksh
#!/bin/ksh platform=$1 lw_platform=$(echo "$platform" | tr '[:upper:]' '[:lower:]') log_dir="/project/$lw_platform/logs/" read_file="/user/LogAnalysis/files.txt" out_file="/user/LogAnalysis/out3.txt" echo $lw_platform echo $log_dir while -r line; do echo "Began: $line" >> $out_file cd ${log_dir} echo $(pwd) egrep -n 'ERROR:' $line >> $out_file echo "End: $line" >> $out_file done < $read_file ERRORCONSOLE OUTPUT
.grep: 0652-033 Cannot open ./code_a.log
test /project/test/logs/ /project/test/logs .grep: 0652-033 Cannot open ./code_a.log However I don't get this error if I run the same egrep command directly into the shell. Proves that I have the permissions to read the file.