shell scripting: sed putting unnecessary parenthesis

the following should match only alphabets and if they are found, should put parenthesis around them. I don't know why it puts them between numbers like below. The following result is in the bash script.

$ echo '13123213'|sed 's/[a-z]*/(&)/g'


This might work for you (GNU sed):

sed 's/[[:alpha:]]\+/(&)/g' file


sed 's/[[:alpha:]]\{1,\}/(&)/g' file


sed 's/[[:alpha:]][[:alpha:]]*/(&)/g' file

Here you go:

echo '13123213'|sed 's/[0-9]/(&)/g'

You do try to match [a-z], but you do not have any letter, so use [0-9] for numbers

Or if you like to get the parentheses around letters:

echo '1312a32z13'|sed 's/[a-z]/(&)/g'

This awk can be used.

echo '13123213'| awk '{gsub(/[0-9]/,"(&)")}1'

echo '13123213'| awk '{for (i=1;i<=NF;i++) $i="("$i")"}1' FS="" OFS=""

Need Your Help

Date range in python where result value must be in string format

python django python-2.7 django-1.4

i want date range between two dates. the result value will be like it should support for string operations or it should be in string.