Re: Please HELP me sed GURU..
Once upon a time Geengun Guim said...
> Hi?
>
> c:\tmp\kbs+-www.kbs.co.kr+-cgi-bin+-test.cgi
> c:\tmp\mbc+-ddd.mbc.co.kr+-cwb-bin+-yes.pl
> c:\tmp\sbs+-sbs.co.kr+-cgi-bin+-ddd.cgi
>
> =>
>
> move c:\tmp\kbs+-www.kbs.co.kr+-cgi-bin+-test.cgi www.kbs.co.kr+-cgi-bin+-test.cgi
> move c:\tmp\mbc+-ddd.mbc.co.kr+-cwb-bin+-yes.pl ddd.mbc.co.kr+-cwb-bin+-yes.pl
> move c:\tmp\sbs+-sbs.co.kr+-cgi-bin+-ddd.cgi sbs.co.kr+-cgi-bin+-ddd.cgi
>
> I don't have whole solution to solve this but have partically.
>
> The first simbol of each lines +-. To solve this, sed -e "s/^[^+]*+-//g" input.txt > output.txt on dos.
> Next, sed -e "s/\(.*\)\(www.*\)/move\ \"\1\2\"\ \2/"
>
> But not actually www. The identifier is the word right after the first +- simbol.
> So, I'd like to combine the first command and the next command.
This seems to work for me:
sed 's/\(^[^+]*+-\)\(.*\)$/move \1\2 \2/'
It will fail is there is a single + character before the first +-
symbol.
Reply to: