Sponsored Content
Top Forums Shell Programming and Scripting Escape characters in a variable Post 303033141 by RudiC on Saturday 30th of March 2019 05:27:36 PM
Old 03-30-2019
Please make it a habit to post your system's info in every single new thread, as you did thankworthily in your very first post in here: "Debian 9 64x - LXDE".


As for your problem: the bash builtin echo needs the -e option. man bash:
Quote:
If the -e option is given, interpretation of the following backslash-escaped characters is enabled.
Same holds true for the external /bin/echo comand on linux systems. It does not necessarily on other systems.



Code:
echo "$red_start This text should be red $color_end"
\e[91m This text should be red \e[0m
echo -e "$red_start This text should be red $color_end"
 This text should be red 

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

lp FormFeed Escape characters

I'm trying to modify the /usr/lib/lp/model/netstandard file to generate a header for all the print jobs that are sent, but there is no formfeed defined so the the job prints right after the header with no page break. What is the sequence I need in order to generate a formfeed? Or, do you have... (4 Replies)
Discussion started by: jgordon
4 Replies

2. Shell Programming and Scripting

number of escape characters?

Hi, I am trying to execute the following command from a batch script, but no matter how many escape characters I put in it doesn't execute properly. It works fine from the command line with quotes around the -exec part. #!/bin/sh /usr/local/bin/sudo /usr/atria/bin/cleartool setview -exec... (0 Replies)
Discussion started by: Sebarry
0 Replies

3. Shell Programming and Scripting

escape characters..

hey i want to know the unix commands to replace all the character escape sequences with their "C" values in a string... thanks in advance..! Regards, Sharanya (9 Replies)
Discussion started by: sharsin2001
9 Replies

4. Shell Programming and Scripting

Searching for escape characters

Hi all I have been trying to write a script to look for a set of specific escape characters in a file. On viewing the file via vi it shows this : ^ I understand this means no end of line. I have tried a vary of grep parameters such as grep ^\^. filename grep --binary-file=binary without... (8 Replies)
Discussion started by: timcs
8 Replies

5. UNIX for Dummies Questions & Answers

Escape Characters on various shells

Hi, I want to know if escape charaters work on all the popular UNIX shells. More specifically I want to know if echo "\c" will work on most of the UNIX shells and are there any specific shells on which \c won't work. Please help. Thanks, Vineet (2 Replies)
Discussion started by: vineetd
2 Replies

6. Shell Programming and Scripting

Removing Escape Sequence Characters

Hi All, I have added the script command to user profile so that to record the on-screen data.But when i i checked the O/P i could see lot of escape sequence is there way to remove it. (2 Replies)
Discussion started by: cutechaps
2 Replies

7. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

8. Shell Programming and Scripting

Escape special characters in SED

Need help in escaping special characters in sed command. Here is the the string which i am trying to find a replace with From :- REQUEST_TYPE=PIXEL&MSG_ID={//MESSAGE_ID} To :- REQUEST_TYPE=PIXEL&MSG_ID= X_EDELIVERY_MESSAGE_ID & BATCH_ID= X_EDELIVERY_BATCH_ID Here is the sed command i am... (2 Replies)
Discussion started by: aakishore
2 Replies

9. Shell Programming and Scripting

Escape characters

i am executing script from A server which will execute the script in B server , as below. ssh A 'ssh B echo 'select * from testing where name ='test'' i am getting the below output. select * from testing where name=test but i need the output where clause with quotes , tried with... (3 Replies)
Discussion started by: expert
3 Replies

10. Shell Programming and Scripting

How to escape all special characters?

I have an application which I am integrating with that accepts the password via a CLI. I am running in to issues with passwords that contain special characters. I tried to escape them all, but I ran in to an issue where I cannot escape the characters ' ] My attempt is as follows: $... (2 Replies)
Discussion started by: AMG1978
2 Replies
IMAGECOLORCLOSESTHWB(3) 						 1						   IMAGECOLORCLOSESTHWB(3)

imagecolorclosesthwb - Get the index of the color which has the hue, white and blackness

SYNOPSIS
int imagecolorclosesthwb (resource $image, int $red, int $green, int $blue) DESCRIPTION
Get the index of the color which has the hue, white and blackness nearest the given color. PARAMETERS
o $ image -An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(3). o $red -Value of red component. o $green -Value of green component. o $blue -Value of blue component. RETURN VALUES
Returns an integer with the index of the color which has the hue, white and blackness nearest the given color. EXAMPLES
Example #1 Example of using imagecolorclosesthwb(3) <?php $im = imagecreatefromgif('php.gif'); echo 'HWB: ' . imagecolorclosesthwb($im, 116, 115, 152); imagedestroy($im); ?> The above example will output something similar to: HWB: 33 CHANGELOG
+--------+--------------------------------------------+ |Version | | | | | | | Description | | | | +--------+--------------------------------------------+ | 5.3.0 | | | | | | | This function is now available on Windows | | | | +--------+--------------------------------------------+ SEE ALSO
imagecolorclosest(3). PHP Documentation Group IMAGECOLORCLOSESTHWB(3)
All times are GMT -4. The time now is 09:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy