Hi,
I need to convert string "(joe.smith" into "joe_smith"
i.e. I need to remove the leading opening brace '(' and replace the dot '.' with an under score '_'
can anyone suggest a one liner ksh script or unix command for this please
Hi,
I need to convert string "(joe.smith" into "joe_smith"
i.e. I need to remove the leading opening brace '(' and replace the dot '.' with an under score '_'
can anyone suggest a one liner ksh script or unix command for this please
In bash/ksh you can do:
$ NAME="(joe.smith"
$ NAME=${NAME#\(}
$ NAME=${NAME/./_}
$ echo $NAME
joe_smith
---------- Post updated at 11:11 AM ---------- Previous update was at 11:03 AM ----------
One lines (lol):
$ NAME="(joe.smith"; TNAME=${NAME#\(}; echo ${TNAME/./_}
joe_smith
$ echo '(joe.smith' | tr -d '(' | tr '.' '_'
joe_smith
$ echo '(joe.smith' | sed -e 's/^(//' -e 's/\./_/'
joe_smith
$ echo '(joe.smith' | awk '{gsub(/^\(/, ""); gsub(/\./, "_")} 1'
joe_smith
For smaller file size or single line..this cud be the best
echo '(joe.smith' |sed 's/^(//g'|sed 's/\./_/g'
Thanks you guys .. it worked !