need a linux command
i have a big log file in a directory.
in this log file , there is line which contains keyword "XML MESSAGE". i want to print -5 lines above and +5 lines below (including that line also) to that line. whats the linux command for this ? |
Code:
cat your_log_file | grep XML MESSAGE -A 5 -B 5 |
Quote:
cat your_log_file | grep "XML MESSAGE" -A 5 -B 5 . please note "XML MESSAGE" is a keyword , a fixed string |
Quote:
Code:
grep XML\ MESSAGE -A5 -B5 your_log_file |
Quote:
not working ! i got the following error msg : grep: can't open -A grep: can't open 5 grep: can't open -B grep: can't open 5 i used this .. vi mylogfile.log | grep "Xml To Publish : " -A 5 -B 5 whats wrong here ? |
Quote:
|
It works for me, using grep-2.5.1-52.2 on FC5.
Quote:
|
You need to use cat, not vi, to display the contents of the file. This:
Code:
vi mylogfile.log | grep "Xml To Publish : " -A 5 -B 5 Code:
cat mylogfile.log | grep "Xml To Publish : " -A 5 -B 5 |
Quote:
see below.. server_dir> cat mylogfile.log | grep "Xml To Publish : " -A 5 -B 5 grep: can't open -A grep: can't open 5 grep: can't open -B grep: can't open 5 |
Quote:
|
do you have any other alternative which could solve the same purpose ?
|
It works quite well! Which version of grep do you have?
|
Quote:
please tell me the command ..i'll check and post it . can you tell any other alternative which could solve my problem ? |
Quote:
or grep --version Quote:
|
Quote:
i found grep -V grep: illegal option -- V Usage: grep -hblcnsviw pattern file . . . i believe this is a unix system ...because tail command works fine in this system.....i work via telnet only....do you think ,..its a unix box ? if so whats the equivalent command in unix which could solve my purpose ? |
All times are GMT -5. The time now is 04:09 PM. |