hi All,
how to find a pattern in the log file & display the above and below line
for example in the log file, i have many lines, whenever i search for "Category" it should display the above line with only few parameter like i want only the location name & department name
Thu Jul 02 11:05:23 2009<location> noth amer</location><Site>ohioc</site><department>IT sales</department><country>UAT</country>
Thu Jul 02 11:05:39 2009 ird: INFO: (pack) We have a Problem Record. pp_HPD: category, Type is invalid
Thu Jul 02 11:05:39 2009 please enter the corrct details
in the below code i'm able to get only the above line
Logn="file name"
for log in $Log
do
cat $log |sed -n -e'/Category/{x;1!p;}' -e h |grep "`date +%a' '%b' '%d`" >> $Logn/System_Log
done
but i'm not getting the custom parmater from the above line