Sponsored Content
Top Forums Shell Programming and Scripting Awk:String search more than one time and capture OP Post 302936836 by jaydeep_sadaria on Saturday 28th of February 2015 09:03:23 AM
Old 02-28-2015
Awk:String search more than one time and capture OP

Dear All

During one of mine script developemnt i am stuch at one sub part. Requiremnt is as below kindly help me.

IP file:
Code:
2015-02-28 10:10:15 AL M UtranCell UtranCell=RTE001X (unavailable)
2015-02-28 10:10:15 AL M UtranCell UtranCell=RTE001Y (unavailable)
2015-02-28 10:10:15 AL M UtranCell UtranCell=RTE001Z (unavailable)
2015-02-28 10:10:17 AL M UtranCell UtranCell=KDA003X (unavailable)
2015-02-28 10:10:17 AL M UtranCell UtranCell=KDA003Y (unavailable)
2015-02-28 10:10:17 AL M UtranCell UtranCell=KDA003Z (unavailable)
2015-02-28 10:12:06 AL * UtranCell UtranCell=KDA003X (unavailable)
2015-02-28 10:12:06 AL * UtranCell UtranCell=KDA003Y (unavailable)
2015-02-28 10:12:06 AL * UtranCell UtranCell=KDA003Z (unavailable)
2015-02-28 10:12:06 AL * UtranCell UtranCell=RTE001X (unavailable)
2015-02-28 10:12:06 AL * UtranCell UtranCell=RTE001Y (unavailable)
2015-02-28 10:12:06 AL * UtranCell UtranCell=RTE001Z (unavailable)
2015-02-28 10:16:50 AL M UtranCell UtranCell=RTE001X (unavailable)
2015-02-28 10:16:50 AL M UtranCell UtranCell=RTE001Y (unavailable)
2015-02-28 10:16:50 AL M UtranCell UtranCell=RTE001Z (unavailable)
2015-02-28 10:16:50 AL M UtranCell UtranCell=KDA003X (unavailable)
2015-02-28 10:16:50 AL M UtranCell UtranCell=KDA003Y (unavailable)
2015-02-28 10:16:50 AL M UtranCell UtranCell=KDA003Z (unavailable)
2015-02-28 10:18:30 AL * UtranCell UtranCell=RTE001X (unavailable)
2015-02-28 10:18:30 AL * UtranCell UtranCell=RTE001Y (unavailable)
2015-02-28 10:18:30 AL * UtranCell UtranCell=RTE001Z (unavailable)

Needed OP:

Here 1st column is site id,2ed/3rd column is down time marker "M" in input file,
4th/5th column is up time marked "*" in input file.
For 2ed occurance on KAD003 site no uptime("*") availalbe in IP file, so we need to right remark that site is still down.

Code:
RTE001X 2015-02-28 10:10:15 2015-02-28 10:12:06
RTE001Y 2015-02-28 10:10:15 2015-02-28 10:12:06
RTE001Z 2015-02-28 10:10:15 2015-02-28 10:12:06
KDA003X 2015-02-28 10:10:17 2015-02-28 10:12:06
KDA003Y 2015-02-28 10:10:17 2015-02-28 10:12:06
KDA003Z 2015-02-28 10:10:17 2015-02-28 10:12:06
RTE001X 2015-02-28 10:16:50 2015-02-28 10:18:30
RTE001Y 2015-02-28 10:16:50 2015-02-28 10:18:30
RTE001Z 2015-02-28 10:16:50 2015-02-28 10:18:30
KDA003X 2015-02-28 10:16:50 Down Down
KDA003Y 2015-02-28 10:16:50 Down Down
KDA003Z 2015-02-28 10:16:50 Down Down

Thanks in advance

Regards
Jaydeep Sadaria
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search string during a specific time frame

Can someone please help me with searching a string during a specific time frame. Below is the format of the time from my log file. "GET /AAM2009_wherewereheaded.wmv HTTP/1.1" 200 52307085 The search string I need is "AAM2009_wherewereheaded.wmv" I need to search the number of... (1 Reply)
Discussion started by: tadi18
1 Replies

2. Shell Programming and Scripting

Awk command for search a string in lspv

I want to know wich hdisk have only one pvid and also display hdisk with two pvid. hdisk1 00c3fcd4e516183f testvg active hdisk2 00c3fcd4e516189b testvg active hdisk3 00c3fcd4e51618ec testvg ... (1 Reply)
Discussion started by: khalidou13
1 Replies

3. Shell Programming and Scripting

Awk - find string, search lines below string for other strings

What's the easiest way to search a file for a specific string and then look for other instances after that? I want to search for all Virtual Hosts and print out the Server Name and Document Root (if it has that info), while discarding the rest of the info. Basically my file looks like this: ...... (6 Replies)
Discussion started by: Mbohmer
6 Replies

4. Shell Programming and Scripting

awk/sed string search and replace

Need help with either sed or awk to acheive the following file1 ----- In the amazon forest The bats eat all the time... mon tue wed they would eat berries In the tropical forest The bats eat all the time... on wed bats eat nuts In the rain forest The bats eat all the time... on... (2 Replies)
Discussion started by: jville
2 Replies

5. Shell Programming and Scripting

awk search between 2 digits a string

I would like to search between two a string. I thought this would be easy. The is always at the beginning of a line. The code: gawk '/^/{d=$1},/searchstring/,/^(d+1)/' or gawk '/^/,/searchstring/,/^/' did not return the desired result. inputfile.txt 999 some text searchstring some... (6 Replies)
Discussion started by: sdf
6 Replies

6. UNIX for Dummies Questions & Answers

Converting string date time to unix time in AWK

I'd like to convert a date string in the form of sun aug 19 09:03:10 EDT 2012, to unixtime timestamp using awk. I tried This is how each line of the file looks like, different date and time in this format Sun Aug 19 08:33:45 EDT 2012, user1(108.6.217.236) all: test on the 17th ... (2 Replies)
Discussion started by: bkkid
2 Replies

7. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

8. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

9. Shell Programming and Scripting

awk : Search for text between two time frame (12 hours)

I have created the script to grep the errors from weblogic logs files and redirecting output to file.txt ...From file.txt I'm using awk command to collect the past 20 mins output...The script running from cron every 15 mins... The script working well... Now the challenges, I'm trying to use... (27 Replies)
Discussion started by: zenkarthi
27 Replies

10. Shell Programming and Scripting

awk help string capture

Dear All My input file as under. From it I want op fine as mention below. Kindly help. I use below code but not help. code: awk -F" " '{print $2}' ip file: "BSCJNGR_IPA17_C" 030 131207 1305 RXOCF-353 PBD011_BGIL BOTH AC FAULTY "BSCJNGR_IPA17_C" 991 131207 1637 RXOCF-224 NAV001_BGIL ... (5 Replies)
Discussion started by: jaydeep_sadaria
5 Replies
DDB(8)							    BSD System Manager's Manual 						    DDB(8)

NAME
ddb -- configure DDB kernel debugger properties SYNOPSIS
ddb capture [-M -core] [-N -system] print ddb capture [-M -core] [-N -system] status ddb script scriptname ddb script scriptname=script ddb scripts ddb unscript scriptname ddb pathname DESCRIPTION
The ddb utility configures certain aspects of the ddb(4) kernel debugger from user space that are not configured at compile-time or easily via sysctl(8) MIB entries. To ease configuration, commands can be put in a file which is processed using ddb as shown in the last synopsis line. An absolute pathname must be used. The file will be read line by line and applied as arguments to the ddb utility. Whitespace at the beginning of lines will be ignored as will lines where the first non-whitespace character is '#'. OUTPUT CAPTURE
The ddb utility can be used to extract the contents of the ddb(4) output capture buffer of the current live kernel, or from the crash dump of a kernel on disk. The following debugger commands are available from the command line: capture [-M core] [-N system] print Print the current contents of the ddb(4) output capture buffer. capture [-M core] [-N system] status Print the current status of the ddb(4) output capture buffer. SCRIPTING
The ddb utility can be used to configure aspects of ddb(4) scripting from user space; scripting support is described in more detail in ddb(4). Each of the debugger commands is available from the command line: script scriptname Print the script named scriptname. script scriptname=script Define a script named scriptname. As many scripts contain characters interpreted in special ways by the shell, it is advisable to enclose script in quotes. scripts List currently defined scripts. unscript scriptname Delete the script named scriptname. EXIT STATUS
The ddb utility exits 0 on success, and >0 if an error occurs. EXAMPLES
The following example defines a script that will execute when the kernel debugger is entered as a result of a break signal: ddb script kdb.enter.break="show pcpu; bt" The following example will delete the script: ddb unscript kdb.enter.break For further examples, see the ddb(4) and textdump(4) manual pages. SEE ALSO
ddb(4), textdump(4), sysctl(8) HISTORY
The ddb utility first appeared in FreeBSD 7.1. AUTHORS
Robert N M Watson BUGS
Ideally, ddb would not exist, as all pertinent aspects of ddb(4) could be configured directly via sysctl(8). BSD
December 24, 2008 BSD
All times are GMT -4. The time now is 01:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy