Sponsored Content
Top Forums Shell Programming and Scripting Disabling Backslash Interpretation with "echo -E"? Post 302687349 by mrm5102 on Thursday 16th of August 2012 11:42:59 AM
Old 08-16-2012
Hey Corona, thanks for the reply...

Yeah funny you say that, I actually just noticed that a little while before I read your post... Thanks!


UPDATE:
So I'm guessing I ran into a little Perl version problem on some of our older servers...
When I ran the REGEX on the machine I'm testing this on, it worked perfectly... But when I transferred it over
to another server running Perl v5.8.2 and another with v5.8.8 it didn't do anything to the "strings" at all.

So what I did was, I tried to simplify the REGEX, because I'm guessing it matched ANY/ALL V100 Character
Sequences, but I ONLY needed to look out for the ones for BOLD "\033[1m", and the one for OFF "\033[0m"
and possibly the one for UNDERLINE "\033[4m"...

Strangely though, those escape sequences above are how you would enter them into a bash script, like this:
i.e. --> echo -e "\033[1m THIS PRINTS BOLD \033[0m"

Then if I redirect the echo statement into a txt file, they show like this instead of what's above...
i.e. --> "^[[1m THIS PRINTS BOLD ^[[0m"


So here's my new REGEX (also I changed the while loop to just a 'cat' command):
Code:
outputFile="/usr/local/test/Output.txt"

### Split the output of the 'cat' command on newlines, and insert it into the array FILE_Lines...
IFS='
'
FILE_Lines=($(cat $outputFile | perl -pe 's/\^\[\[(1|0|4)m//g'))

for (( x=0; x<=${#NRPE_Lines[@]}; x++ ))
 do
    echo ${NRPE_Lines[$x]}
done

So far this seems to remove ALL the escape sequences from the file, so I guess
I'll use this one until or if/when something else goes wrong lol...



Thanks again you guys for your suggestions... Much appreciated!!


Thanks Again,
Matt
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Interpretation of "echo $-"

I am running Solaris 10. Can someone help me interpret the output from "echo $-"? Interactively, the output is: ism From within a cron job, the output is: xh Why are they different? Can someone point me to the appropriate documentation? Thanks, J (1 Reply)
Discussion started by: shew01
1 Replies

2. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

Hi, I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
Discussion started by: jockey007
7 Replies

3. Shell Programming and Scripting

Difference between using "echo" builtin and /bin/echo

So in my shell i execute: { while true; do echo string; sleep 1; done } | read line This waits one second and returns. But { while true; do /bin/echo string; sleep 1; done } | read line continues to run, and doesn't stop until i kill it explicitly. I have tried this in bash as well as zsh,... (2 Replies)
Discussion started by: ulidtko
2 Replies

4. Shell Programming and Scripting

With that logic this echoes "echo". Question about echo!

echo `echo ` doesn't echoes anything. And it's logic. But echo `echo `echo ` ` does echoes "echo". What's the logic of it? the `echo `echo ` inside of the whole (first) echo, echoes nothing, so the first echo have to echo nothing but echoes "echo" (too much echoing :P):o (2 Replies)
Discussion started by: hakermania
2 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. AIX

echo $varibla | mail -s "subject" "xxx@xxx.com" not ruuning as expected

Hi Folks, As per the subject, the following command is not working as expected. echo $variable | mail -s "subject" "xxx@xxx.com" Could anyone figure it out whats wrong with this. I am using AIX box. Regards, (2 Replies)
Discussion started by: gjarms
2 Replies

7. Shell Programming and Scripting

tcsh - understanding difference between "echo string" and "echo string > /dev/stdout"

I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here. I have following script (called out_to_streams.csh): #!/bin/tcsh -f echo Redirected to STDOUT > /dev/stdout echo Redirected to... (2 Replies)
Discussion started by: marcink
2 Replies

8. Shell Programming and Scripting

sed command escaping backslash "/"

Hello friends/'unix experts', i have a file as below cat sample.txt satish /rakesh/ sandhya /sandeep/ i have to replace /rakesh/ with rakesh, how can i do it with sed, i tried below code but its throwing errors sed -e 's/'"\(/rakesh/)\"'/\1rakesh/g' sample.txt ... (1 Reply)
Discussion started by: only4satish
1 Replies

9. Shell Programming and Scripting

Escaping backslash and asterisk in egrep to match "\*"

So far what i've got is egrep '^(\\)\*$'No luck. I've searched the web and not much luck. I know about the escape character \ but its confusing to figure out how to use it to match a backslash and use it to escape the asterisk also. Any ides? Thanks! (8 Replies)
Discussion started by: matthewfs
8 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
AMANDA-SCRIPTS(7)						    Miscellanea 						 AMANDA-SCRIPTS(7)

NAME
amanda-scripts - Configuring and using the Script API DESCRIPTION
The Script API is a flexible system for invoking user-supplied scripts at various points in the execution of Amanda. This manual page describes the operation and configuration of the API. For help writing Script API scripts, see http://wiki.zmanda.com/index.php/Script_API. SCRIPTS
This section lists the scripts included with Amanda, see the individual man page for instructions on using them. For complete How-To information, consult the Amanda wiki at http://wiki.zmanda.com. o amzfs-snapshot(8), - create/destroy zfs snapshot. o script-email(8), - send email. Script properties work just like application properties: they are insensitive to case, and - (dash) and _ (underscore) may be used interchangeably. SCRIPTS OUTPUT PROPERTY
A pre-dle-amcheck, pre-dle-estimate or pre-dle-backup executed on the client can output property on stdout that are sent to the application. If the output line matches "PROPERTY str1 str2", Amanda sets a property called "str1" by the value of "str2", that property is sent to the application. SEE ALSO
amanda(8), amanda.conf(5) The Amanda Wiki: : http://wiki.zmanda.com/ AUTHORS
Jean-Louis Martineau <martineau@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Dustin J. Mitchell <dustin@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Amanda 3.3.3 01/10/2013 AMANDA-SCRIPTS(7)
All times are GMT -4. The time now is 06:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy