Unusual output of sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unusual output of sed
# 1  
Old 05-24-2016
Unusual output of sed

i have a sed command that is looking for the workds OK, WARNING and CRITICAL and add html color to those words. e.g:
Code:
echo $CONSUMABLE |$SED s/OK./\<span\ style\=\"background-color\:green\;font-weight\:bold\;\"\>OK\<\\\/span\>/g

the output breaks every so often and changes my output as following:
Code:
<span style="backg" round-color:green;font-weight:bold;="">OK</span>

i cannot find what is causing this strange behavior or how to fix this.

can anyone help me understand what i am doing wrong?

Last edited by vbe; 05-24-2016 at 11:53 AM..
# 2  
Old 05-24-2016
Looks like your quoting is a bit crazy. This works and is easier to read:

Code:
echo "$consumable" | sed 's#OK.#<span style="background-color:green;font-weight:bold;">OK</span>#g'

# 3  
Old 05-24-2016
Code:
echo "$consumable" | sed '
s#OK#<span style="background-color:green;font-weight:bold;">OK</span>#g
s#WARNING#<span style="background-color:orange;font-weight:bold;">WARNING</span>#g
s#CRITICAL#<span style="background-color:red;font-weight:bold;">CRITICAL</span>#g
'

# 4  
Old 05-24-2016
i am still getting some unexpected results:

<span style="backgr
ound-color:green;font-weight:bold;">OK</span>



<span style="background-color:green;font-weight:bold;">OK</spa>


i cannot understand what they have in common or why my results give me weird printing but only on one or 2 lines...
# 5  
Old 05-24-2016
Please show us exactly what you are running, word for word, letter for letter, keystroke for keystroke. Also show all relevant input.
# 6  
Old 05-24-2016
Code:
CONSUMABLE="`$SNMPCHECKCMD -H ${PRINTERS[$PRINTER]} -C public -x \"CONSUM ALL\" -w 15 -c 10 |$SED  s/\!/\ \<br\>/g |$SED s/\|.*//g`"
CONSUMABLE="`echo $CONSUMABLE |$SED '
s#OK.#<span style="background-color:green;font-weight:bold;">OK</span>#g
s#WARNING.#<span style="background-color:orange;font-weight:bold;">WARNING</span>#g
s#CRITICAL.#<span style="background-color:red;font-weight:bold;">CRITICAL</span>#g'`"
OUTPUT+=$CONSUMABLE


Last edited by Corona688; 05-24-2016 at 03:44 PM..
# 7  
Old 05-24-2016
What does the value of CONSUMABLE end up being after this line?
Code:
CONSUMABLE="`$SNMPCHECKCMD -H ${PRINTERS[$PRINTER]} -C public -x \"CONSUM ALL\" -w 15 -c 10 |$SED  s/\!/\ \<br\>/g |$SED s/\|.*//g`"

Also, what is the value of SED?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Unusual system bog down

Solaris 10 10/09 s10s_u8wos_08a SPARC 16cpus 128MB, uptime 150+ days, 2 db zones (Oracle 9 & 10), 3 application zones. This is from a system that was literally crawling, 60 seconds to execute a single command. I had to reboot to clear it. Data is from runs of prstat and top, and iostat. ... (3 Replies)
Discussion started by: jim mcnamara
3 Replies

2. HP-UX

Unusual Behavior?

Our comp-operator has come across a peculiar ‘feature'. We have this directory where we save all the reports that were generated for a particular department for only one calendar year. Currently there are 45,869 files. When the operator tried to backup that drive it started to print a flie-listing... (3 Replies)
Discussion started by: vslewis
3 Replies

3. Shell Programming and Scripting

Unusual Problem

what is wrong with the below script: --------------------------------------------------------------------------------- #!/bin/bash echo "Setting JrePath..." grep -w "export JrePath" /etc/profile Export_Status=$? if echo "JrePath declared" elif echo "JrePath not declared" echo... (4 Replies)
Discussion started by: proactiveaditya
4 Replies

4. UNIX for Dummies Questions & Answers

SED: Can't Repeat Search Character in SED Output

I'm not sure if the problem I'm seeing is an artifact of sed or simply a beginner's mistake. Here's the problem: I want to add a zero-width space following each underscore between XML tags. For example, if I had the following xml: <MY_BIG_TAG>This_is_a_test</MY_BIG_TAG> It should look like... (8 Replies)
Discussion started by: rhetoric101
8 Replies

5. Programming

C Calender Help - Unusual error

I'm making a program that you input the month and year, and it creates a calender for that month of that year. This is my largest project yet, and I broke it up into several source files. cal.c #include "cal.h" #include <stdio.h> main() { int month, year; scanf("%d %d", &month,... (3 Replies)
Discussion started by: Octal
3 Replies

6. Shell Programming and Scripting

very unusual question about while

is there anyway to make while run a command faster than per second? timed=60 while do command sleep 1 done i need something that can run a script for me more than one time in one second. can someone help me out here? (3 Replies)
Discussion started by: Terrible
3 Replies

7. UNIX for Advanced & Expert Users

unusual function refrences

I'm wrting a program which needs to get the following information of a sever by calling some lib fuctions or system calls, so can anybody help to tell me those function names or where I can find the description of them ? CPU usage Memory usage Load procs per min Swap usage Page I/O Net I/O... (1 Reply)
Discussion started by: xbjxbj
1 Replies

8. UNIX for Dummies Questions & Answers

somewhat unusual top output problem

i'm a relative newbie to unix (i'm on OSX) and i have a specific problem i'm tripped up on: i'm piping the output of top (in log format) into an awk command which formats the information (and eventually will send it out continuously via udp/osc to another app). my problem is with what comes up... (4 Replies)
Discussion started by: ohhmyhead
4 Replies

9. Shell Programming and Scripting

Deleting an unusual file

Hi everyone, I was doing some practising with Unix and accidentally created a file with the name -------------------- Yeah, it was UNINTENTIONALLY. I tried removing it various ways like rm '--------------' rm '-.*' and all other sorts, but Unix keeps detecting that as an option stuff... ... (2 Replies)
Discussion started by: scmay
2 Replies
Login or Register to Ask a Question