Sponsored Content
Top Forums Shell Programming and Scripting Regex in sed to find specific pattern and assign to variable Post 302881590 by RudiC on Monday 30th of December 2013 11:41:02 AM
Old 12-30-2013
Not clear. We have lines, that have SEV in them, lines with SEV and ATOM, others with those two and COUNT, and many not having any of those. On top, the Guessing wildly, I infer that in a shell loop you want to assign those three values to three variables, but only from lines that have all three in them? Try this:
Code:
sed -nr 's/COUNT=([^;]*).*ATOM=([^;]*).*SEV=([^;]*).*/\1 \2 \3/p' file | while read A B C; do echo $C $B $A; done
Critical KLZCPU.CPUID 3
Warning KLZCPU.CPUID 3
Critical LNXPROC.CMD 3
Critical LNXPROC.PID 4
Critical KLZNET.FIPADDR 3

This depends on the three values to occur in the same sequence in all lines. If that's not the case, you'd need to use e.g. awk.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to assign value to a variable with row(using -n) returned by sed

Hi Friends, REQUIREMENT: Want to delete files from the current directory match with the same in the file test.txt set -x i=1 echo "i=$i" COUNT=`sed -n '$=' test.txt` echo "Count=$COUNT" while do "## Here is error##" FILETOREMOVE=`sed -n \'$i,1p\' test.txt` echo $FILETOREMOVE... (5 Replies)
Discussion started by: sourabhsharma
5 Replies

2. Shell Programming and Scripting

sed to awk (regex pattern) how?

Hello, I am trying to covert a for statement into a single awk script and I've got everything but one part. I also need to execute an external script when "not found", how can I do that ? for TXT in `find debugme -name "*.txt"` ;do FPATH=`echo $TXT | sed 's/\(.*\)\/\(.*\)/\1/'` how... (7 Replies)
Discussion started by: TehOne
7 Replies

3. Shell Programming and Scripting

How to assign the Pattern Search string as Input Variable

guys, I need to know how to assing pattern matched string as an input command variable. Here it goes' My script is something like this. ./routing.sh <Server> <enable|disable> ## This Script takes an input <Server> variable from this line of the script ## echo $1 | egrep... (1 Reply)
Discussion started by: raghunsi
1 Replies

4. UNIX for Dummies Questions & Answers

blank space in regex pattern using sed

why does sed 's/.* //' show the last word in a line and sed 's/ .*//' show the first word in a line? How is that blank space before or after the ".*" being interpreted in the regex? i would think the first example would delete the first word and the next example would delete the second... (1 Reply)
Discussion started by: glev2005
1 Replies

5. Shell Programming and Scripting

SED Replacing all but one regex match on a line or specific matches

Hi, I'm attempting to rename some files that have spaces in them. Without linking sed commands together is it possible to replace the first three "." to " ". File.name.is.long.ext -> File name is long.ext I can get the desired effect with echo "File.name.is.long.ext" | sed 's/\./ /g;s/... (5 Replies)
Discussion started by: vectox
5 Replies

6. Shell Programming and Scripting

SED: Pattern repitition regex matching

Fairly straightforward, but I'm having an awful time getting what I thought was a simple regex to work. I'll give the command I was playing with, and I'm aware why this one doesn't work (the 1,3 is off the A-Z, not the whole expression), I just don't know what the fix is: Actual Output(s): $... (5 Replies)
Discussion started by: Vryali
5 Replies

7. Shell Programming and Scripting

Why regex pattern doesn't work in find?

$ find /opt/data_* -maxdepth 3 -type d -name "main*" 2> /dev/null /opt/data_025/maindblogs /opt/data_026/maindblogs /opt/data_027/maindblogs /opt/data_028/maindblogs $ find /opt/data_* -maxdepth 3 -type d -name "rvlogs*" 2> /dev/null /opt/data_002/prod/rvlogs2_archive... (4 Replies)
Discussion started by: urello
4 Replies

8. Shell Programming and Scripting

How to find a file with a specific pattern for current sysdate & upon find email the details?

I need assistance with following requirement, I am new to Unix. I want to do the following task but stuck with file creation date(sysdate) Following is the requirement I need to create a script that will read the abc/xyz/klm folder and look for *.err files for that day’s date and then send an... (4 Replies)
Discussion started by: PreetArul
4 Replies

9. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies
HOBBIT-CONFREPORT.CGI(1)				      General Commands Manual					  HOBBIT-CONFREPORT.CGI(1)

NAME
hobbit-confreport.cgi - Xymon Configuration report SYNOPSIS
hobbit-confreport.cgi DESCRIPTION
hobbit-confreport.cgi is invoked as a CGI script via the hobbit-confreport.sh CGI wrapper. hobbit-confreport.cgi provides a plain HTML (Web) report of the Xymon configuration for a group of hosts; which hosts are included is determined by the hosts available on the webpage from where the CGI script is invoked. The configuration report include the hostnames, a list of the statuses monitored for each host, and if applicable any configuration set- tings affecting these. Alerts that may be triggered by status changes are also included. The report is plain HTML without any images included, and therefore suitable for inclusion into e-mails or other documents that may be accessed outside the Xymon system. OPTIONS
--critical Report only on the statuses that are configured to show up on the Critical Systems view. --old-nk-config Use the deprecated NK tag in bb-hosts to determine if tests appear on the Critical Systems view. --env=FILENAME Loads the environment defined in FILENAME before executing the CGI script. --area=NAME Load environment variables for a specific area. NB: if used, this option must appear before any --env=FILENAME option. --debug Enables debugging output. BUGS
Client-side configuration done in the hobbit-clients.cfg(5) is not currently reflected in the report. Critical Systems view configuration is not reflected in the report. SEE ALSO
bb-hosts(5), hobbit-alerts.cfg(5), hobbit-clients.cfg(5), xymon(7) Xymon Version 4.2.3: 4 Feb 2009 HOBBIT-CONFREPORT.CGI(1)
All times are GMT -4. The time now is 06:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy