Splitting a string in Korn shell

September 14, 2011 at 13:35:52
Specs: Windows XP
I am trying to parse and split a string and then concatenate part it with another in the following way:
input '/cygwin/c/folder_name'
split it into '/cygwin/c' and '/folder_name' and then concatenate it so it that it returns
'C:/folder_name'


See More: Splitting a string in Korn shell

Report •

#1
September 14, 2011 at 15:03:15
I am not a cygwin user so this was done on a Solaris 9 box using the ksh pattern matching operators:

#!/bin/ksh

str="/cygwin/c/folder_name"

newstr=${str##*/} # gets the basename like the unix basename command
newvar="C:/$newstr"
echo "$newvar"


Report •

#2
September 14, 2011 at 20:07:46
Thx
Worked fine

Report •
Related Solutions


Ask Question