The code I gave you was not:
It was:
and the output is not the same. This script only prints the lines requested:
(The lines between the line containing <cisco:subportname> and the line containing </cisco:subportname>; not those two lines and the lines between them.)
The variable p is a flag that causes input lines to be printed when p is non-zero. The initial value of any awk variable that has never been set is 0 or an empty string (depending on context). The code in orange turns printing on for following lines when the string <cisco:subportname> is the first string on the line (after any leading whitespace characters).
The code in green turns printing off for that line and following lines when the string </cisco:subportname> is the first string on the line (after any leading whitespace characters).
The code in red prints the current input line if p is set to 1 and does nothing if p is set to 0 or is an empty string. (When a condition evaluates to true [any non-zero numeric value or non-empty string] and there is no action specified, the default action is to print the current input line.)
Last edited by Don Cragun; 07-04-2013 at 06:28 AM..
Reason: Fix typo
This User Gave Thanks to Don Cragun For This Post:
Hi,
Can any one pelase tell me how to grep multiple strings from multiple files in a singel folder?
grep -E "string1|string2|string3|string4|string..."
its taking lots of time..
can any please tell me fast grep???
URGENT (10 Replies)
Hello All,
I have a big file about 1000 lines. Now i am trying to grep a particular string and printing the lines from the string.
say for example in 500th line i have the date as "Mon Wed 14 20:15:24 2010". now i in my case i need to grep the combination of the strings "Mon Wed 14" and the... (7 Replies)
I have a script that periodically checks the Apache error_log to search for a specific error that causes it to hand and, if found, it restarts the service.
I recently found another error that forces it to hand and won't serve pages until it is reset. What I'm trying to do is to get the script to... (3 Replies)
I have this code
TrackingId:1362412470675;MSISDN:; INFO - number of clietns:3:Received response is: EMSResponse , protocolVersion=5, purchaseOptions=null, serviceData=ServiceData , screenData=CanvasData ]], title=null, titleResource=MessageResource], screenType=null]], serviceId=idBamboo,... (7 Replies)
Hi I have the server.log file as:
Server Stopped
ABC
DEF
GHI
JKL
Server Started
MNO
PQR
STU
Server Stopped
VWX
YZ
ABC
Server Started
Server Stopped
123
456
789 (9 Replies)
Hi,
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.94 Safari/537.36
How can I grep for the strings chrome and safari from a file, and if chrome print Chrome/40.0.2214.94 to a file and also count the number of times chrome is found?
... (4 Replies)
Hi All,
Good morning
I have a below code which is working & getting expected output. the problem in this code is it is executing 3 if conditions, my requirement is
suppose if first condition is success then it should print echo statement & exit from if condition
else if the 1st if condition... (4 Replies)
Hi Experts,
I am writing a python script to grep string from file and display output in csv file as in attached screenshot
https://drive.google.com/file/d/1gfUUdfmQma33tz65NskThYDhkZUGQO0H/view
Input file(result_EPFT_config_device)
Below is the python script i have prepared as of... (1 Reply)