Results 1 to 5 of 5
Hello All,
I have used grep coomand in one of my scripts in which I have used grep as :
newmailto="$(echo "$1" | grep -v '[^0-9A-z_---@.]')"
where I am passing ...
- 11-24-2008 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 6
grep giving error :Invalid Range end
Hello All,
I have used grep coomand in one of my scripts in which I have used grep as :
newmailto="$(echo "$1" | grep -v '[^0-9A-z_---@.]')"
where I am passing $1 as one emailid. It works fine in Unix but as we are going to migrate to Linux . It fails in Linux and gives error as "grep : Invalid Range end".
Please suggest me what changes or substitutions I need to do to rectify this error.
Thanks in Advance !!!!
- 11-24-2008 #2Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
The problem is "---" within the range. What is that supposed to match?
- 11-24-2008 #3Just Joined!
- Join Date
- Nov 2008
- Posts
- 6
Even I am not sure of what "---" matches probably some special characters. But if I replace "---" with "-" it doesn't assign any value to variable newmailto,if I do "echo $newmailto after running this cmd ,it shows blank instead of mailid which I have passed as $1. So what changes I should do to rectify it?
Thnks
- 11-24-2008 #4Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Well, if you don't know what the pattern is supposed to match, how are we supposed to suggest an alternative? At any rate, you can't just replace "---" with "-", since "-" has a special meaning within ranges. At the very least, you need to place a single "-" that is supposed to match "-" at the beginning or end of the range expression. Furthermore, the interpretation of ranges depends on collating order and is not very portable, so try to avoid them wherever possible.
- 11-24-2008 #5Just Joined!
- Join Date
- Jun 2006
- Posts
- 40
Hi Isha,
what's the input string that you're passing as "$1" and what's the output as newmailto, you're getting from your Unix console?
Please provide the desired string which you want to see in linux console.
Thanks
Pawan


Reply With Quote