Regular Expressions

How can i create a regular expression which can detect a new line charcter followed by a special character say * and replace these both by a string of zero length?

Eg:
Input File san.txt

hello
hi
*User
Good
*Morning
Good
Bye

Applying sed command

sed 's/Reg.Expr/g' san.txt
--------------------------------------->

Desired output

hello
hiUser
GoodMorning
Good
Bye

What should be the value of Reg.Expr i.e. Regular Expression to get the desired output??

Please help

sed 's/^\*//s' filename

I tried that but it is not giving the desired output

$ sed 's/^\*//g' san.txt
hello
hi
User
Good
Morning
Good
Bye

Desired Output is
hello
hiUser
GoodMorning
Good
Bye

I don't know how to do that with sed, I guess. awk works:


awk 'BEGIN{ getline; printf "%s", $0}
    { if(substr($0,1,1)=="*"){
         printf "%s", substr($0,2)
      }
      else {
         printf "\n%s", $0
      }
    }    
     END{printf "\n"} 
     ' filename

Thank you so much...it worked for me.
I am a newbie to shell scripts and slowly working out my way. I have been trying this since two days but couldnt make out.

Thanks again

What about this:

sed 'N;s/\n\*//;P;D;' san.txt

Regards,
Tayyab

BEGIN {lastString="";}
{	curStr=$0;
	if (substr(curStr,1,1)=="*") {
		len = length(lastString);
		print substr(lastString,1,len) substr(curStr,2);
	}else{
		print substr(curStr,1)
	}
	lastString = curStr;
}