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
SECURETTY(5)						     Linux Programmer's Manual						      SECURETTY(5)

NAME
securetty - file which lists terminals from which root can log in DESCRIPTION
The file /etc/securetty contains the names of terminals (one per line, without leading /dev/) which are considered secure for the transmis- sion of certain authentication tokens. It is used by (some versions of) login(1) to restrict the terminals on which root is allowed to login. See login.defs(5) if you use the shadow suite. On PAM enabled systems, it is used for the same purpose by pam_securetty(8) to restrict the terminals on which empty passwords are accepted. FILES
/etc/securetty SEE ALSO
login(1), login.defs(5), pam_securetty(8) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2015-03-29 SECURETTY(5)
All times are GMT -4. The time now is 06:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy