Hi Sumit,

Depending on your version of sed, you can probably use :

sed with BRE (Basic Regular Expressions
echo ",john,0019,0314,None,0416,0515,junk" | sed
's/\([^0-9]*\)\([0-9]\{4\}\)\([^0-9]*\)/wxyz_\2 /g'

OR sed with Extended Regular Expressions

For Linux :
echo ",john,0019,0314,None,0416,0515,junk" | sed -r
's/([^0-9]*)([0-9]{4})([^0-9]*)/wxyz_\2
/g'
For BSD :
echo ",john,0019,0314,None,0416,0515,junk" | sed
-E's/([^0-9]*)([0-9]{4})([^0-9]*)/wxyz_\2 /g'

Please let us know if this works or if you need to extend this. 

Thanks!
John

On Dec 18, 2007 4:22 PM, Aditya Lal <[EMAIL PROTECTED]> wrote:

>   hi,
>
> echo ",0019,0314,None,0416,0515" | tr ',' '\012' | grep
> '^[0-9][0-9][0-9][0-9]$' | sed 's/^/wxyz_/' | tr '\012' ' '
>
> Aditya
>
>
> ----- Original Message ----
> From: Sumit Upadhyay <[EMAIL PROTECTED] <sumit.techie%40gmail.com>>
> To: [email protected] <twincling%40yahoogroups.com>
> Sent: Monday, December 17, 2007 5:46:11 PM
> Subject: [twincling] Korn shell query
>
> Hi,
>
> ",0019,0314,None"
>
> Above is the String I have.
> Now I want it to convert it into something.
> "wxyz_0019 wxyz_0314"
> "None" should be ignored.
> a 4 digit valid number should be used only.
> `echo $VAR |cut -d, -f2 can give one of them.
>
> The given string is not fix.
> It may be sometimes ",0019,0314,None,0416,0515"
> Then resulted string should be "wxyz_0019 wxyz_0314 wxyz_0416
> wxyz_0515".
>
> I can do this quite easily in Perl.
> But i need to do this in Korn Shell.
>
> appreciate the response.
>
> thanks
> Sumit

Reply via email to