LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   excluding an echo result (https://www.linuxquestions.org/questions/linux-newbie-8/excluding-an-echo-result-782134/)

Msutantri 01-14-2010 04:08 AM

excluding an echo result
 
Hi guys,

I have a question on how to exclude my echo result, currently I'm having a script running:

echo "parameter Value =" $mc_parameter_value >> $TMPFILE

the value is actually causing a problem for me, since the result is giving me unnecessary result, If i have a "*" in the string then it will actually echo the directory content and i don't want this...

So basically I want to exclude reading the "*" in the line.
Since * is a wild card if I put a simple exclusion putting * in there won't it just ignore the whole thing? any one have any idea of doing this?

evo2 01-14-2010 04:20 AM

How about:

Code:

echo "parameter Value = $mc_parameter_value" >> $TMPFILE
Works?

If not, how are you setting mc_parameter_value?

Evo2.

jschiwal 01-14-2010 05:06 AM

Please provide more details on how you set the $mc_parameter_value variable.

It would help if we could replicate your results.

If the asterisk is separated by spaces, then evaluating the variable will have the asterisk expand to the files in the directory.
For example: value="abc * def" will will have the asterisk expanded.
For "abc*def", "abc* def", "abc *def" it won't be.

If you put the variable inside double quotes, then the asterisk isn't expanded:
echo "parameter Value = $mc_parameter_value" >> $TMPFILE

Msutantri 01-14-2010 06:26 AM

Hmmm actually I have never tried to have the not asterix separated, but actually I don't have any control over how the string will look like.

But the value of the parameter value is actually passed over by other application which reads through a content of log then this script will actually capture it and passing it so an email will have this parameter value.

For ex:

Monitoring log application will search for a string "abc * abc", the string matched in a log will trigger a notification and pass it to event monitoring application, from that application the information will be pass over to an email, and this script is filling the information inside that mail.
echo "parameter Value = $mc_parameter_value" >> $TMPFILE is only part of the script.
And yes when the script is echo ing the $mc_parameter_value since it has * in there, it actually echo ing the content of the directory where the script reside.

evo2 01-14-2010 06:46 AM

If you are replying to questions can you please quote them inline so that we can follow what your have answered. It's hard to tell what is your text, where you are quoting someone else, where you are answering specific questions etc.

Evo2.

Msutantri 01-21-2010 09:16 PM

found the solution...

using the sed function.

"$parameter_value" | 'sed/*//g' >>> TMPFILE

:D


All times are GMT -5. The time now is 09:26 AM.