LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2010, 04:08 AM   #1
Msutantri
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
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?

Last edited by Msutantri; 01-14-2010 at 04:10 AM.
 
Old 01-14-2010, 04:20 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
How about:

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

If not, how are you setting mc_parameter_value?

Evo2.

Last edited by evo2; 01-14-2010 at 04:22 AM.
 
Old 01-14-2010, 05:06 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
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
 
Old 01-14-2010, 06:26 AM   #4
Msutantri
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Original Poster
Rep: Reputation: 0
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.

Last edited by Msutantri; 01-14-2010 at 11:16 PM.
 
Old 01-14-2010, 06:46 AM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
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.
 
Old 01-21-2010, 09:16 PM   #6
Msutantri
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Original Poster
Rep: Reputation: 0
found the solution...

using the sed function.

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

 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ls | echo, I got blank, why can't echo take the 2nd seat in a pipeline? elinuxqs Linux - Newbie 6 11-24-2006 08:25 AM
Excluding Folders with CP Luke_C Linux - General 17 07-27-2006 04:22 AM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 02:59 PM
tar and excluding files murshed Linux - Newbie 7 03-15-2003 02:32 PM
Echo /devPrinting doesn't work, echo /usb/lp0 works, Testpage works, Printing doesn't Hegemon Linux - General 3 08-15-2002 01:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration