Grepping string from out file

Guys ..

Need to pull this highlighted strings irrespective of line numbers & should be echoed . But these strings are from Outfile from different dir. In which way this can be grepped ?? Need an idea

http-timeout 120 seconds
 persistent-timeout 180 seconds
 host-rewriting on
 silence-warning off
 compression off
 include-response-type-encoding off
 always-show-errors off
 disallow-get off
[Services](config http Firewall)# [Services](config http Firewall)#  admin-state enabled
 ip-address LocalIP
 summary admin-state
 priority normal
 port 9091
 http-timeout 120 seconds
 persistent-timeout 180 seconds
 host-rewriting on
 silence-warning off
 compression off
 include-response-type-encoding off
 always-show-errors off
 disallow-get off
 disallow-empty-reply off
 persistent-connections on
 client-address X-Client-IP
 httpproxy-port 800
 version HTTP/1.1 HTTP/1.1
 chunked-uploads off
  monitor-processing-policy terminate-at-first-throttle
 debug-mode off
 debug-history 25
 type loopback-proxy
 attachment-byte-count 2000000000 bytes
 attachment-package-byte-count 0 bytes
 external-references forbid
[Services](config http Firewall)# [Services](config)# Overwrite previously saved configuration? [y/n]: Configuration saved successfully.
[Services](config)# [Services]# Goodbye

Thanks in Advance

didn't get your requirement.
the above data is available in a file a guess?

Haven't tested this, but if I understand you correctly, use awk/nawk/gawk

nawk -F# '/[Services]/{print $NF}' <file>

This says...
On any line in the file that includes [Services], split the line into fields with the # character and print out the last field

If you want to see the three lines which contain the highlighted strings:

egrep "admin-state enabled|Configuration saved successfully|Goodbye" different_dir/Outfile

Somewhat similar:

grep -o '#[^#]*' FILE
# [Services](config http Firewall)
#  admin-state enabled
# [Services](config)
# Overwrite previously saved configuration? [y/n]: Configuration saved successfully.
# [Services]
# Goodbye

If you would want to grep out using regex, then you should have to have some relationship between all the data which you want. Then only you can pull it off ?!

Kindly clarify your requirement better.

Methyl ,

Yes .. your syntax is correct. It worked . But i want the script to ignore prefix's to the argument . Just see below the output of my script.

$ ./routing.sh tmox3456 enable

*******************************************************
 Preparing to service the request for  Device tmox3456 in Question . . .
*******************************************************


 Request authenticated

 Enabling the Device in few seconds
 Report Logging . .

Wed Feb 3 22:10:44 CST 2010

xi[Services](config http Firewall)# xi[Services](config http Firewall)#admin-state enabled
xi[Services](config http Firewall)# xi[Services](config)# Overwrite previously saved configuration? [y/n]: Configuration saved successfully.
xi[Services](config)# xi[Services]# Goodbye

The above status is the string grepped from ${HOME}/out/OutFile . I want ony the String that shows the changes done successfully , as mentioned above.

My part of the script as good as generating the log, but failing to pull the prescribed data from the log which is already been discussed above.

Can someone please update ,.. me get the desired out put.

#
# Apply the changes
#
DATE=`date`
NEWFILE=$OUTFILE$(date +%y%m%d-%H%M%S).${DPDEVICE}.${2}
ssh -T ${DPDEVICE} < $INFILE >> $OUTFILE
if [ $? -eq 0 ]
then
   echo " Report Logging . . "
   echo
   echo " $DATE "
   echo
   mv -if $OUTFILE $NEWFILE
   chmod 755 $NEWFILE
   egrep "admin-state *.*|Configuration saved successfully|Goodbye"
else
   echo " Conection error.Please Validate the NODE name"
fi

Desired Output

./routing.sh tmox3456 enable

*******************************************************
 Preparing to service the request for  Device tmox3456 in Question . . .
*******************************************************


 Request authenticated

 Enabling the Device in few seconds
 Report Logging . .

Wed Feb 3 22:10:44 CST 2010

admin-state enabled or  disabled
Overwrite previously saved 
Configuration saved successfully.
Goodbye

For the admin-state the argument is either enable or disable which is there in the log.
Rest is also the tail of the logs.

You might try this, however it will not echo the "Overwrite previously saved":

grep '#' /diff_dir/outfile | awk -F'#' '{print $NF}' | awk -F':' '{print $NF}'