i have a folder called 'error' and in that, i have error log
files which are generated by the build,
now i want to findout the string 'error' from each log
file and that error has to be copied into the another file
called 'analysis'.
how do you do this in perl?
Answer Posted / prabhath kota
We can do it in a simple way through command line with the
use of grep functionality without writing a program for that.
Suppose your log files(err.log, err_others.log, ......) are
present in "logs" folder.
1) Go to that path first
2) logs]# grep -ir 'error' . > result.txt
(-i for ignore case, -r for recursive search)
3) Observe that, it will grep all the places where ever
'error' is present and keep it in result.txt
4) If you just want the file names alone which contains 'error'
logs]# grep -irl 'error' . > result.txt
(-i for ignore case, -r for recursive search,
-l for listing the files)
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Does Perl have reference type?
What does read () command do?
What does a die() function do in perl?
What is perl push array function?
What does this symbol mean '->'?
How to know whether a key exists or not in perl?
How to open and read data files with Perl
How to do comment in perl?
What does 'do' statement do in perl?
How to deleting an existing file in perl programming?
Explain ivalue in perl?
Explain gmtime() function in perl?
Define operators used in perl?
Show the use of sockets for the server and client side of a conversation?
What is chomp() operator/function?