Sponsored Content
Top Forums Shell Programming and Scripting [[HelloInCapitals]] to [[Hello In Capitals]] Post 302360171 by vgersh99 on Thursday 8th of October 2009 08:53:11 AM
Old 10-08-2009
Wrench

Quote:
Originally Posted by aigles
Smilie
Just a little improvement to avoid iuseless spaces before and after [[ ]]
Code:
echo '[[HelloInCapitals]] or [[PharmaceuticalSocietyOfGreatBritainVBoots1952]]' | 
nawk -F'(\\[\\[)|(\\]\\])' '{for(i=2;i<=NF;i+=2) {gsub("[A-Z]", " &", $i);$i="[["substr($i,2)"]]"};print}' OFS=""

Jean-Pierre.
yep, caught that one as well.
also taking care of 'numbers':
Code:
echo '[[HelloInCapitals]] OrAnd [[PharmaceuticalSocietyOfGreatBritainVBoots1952]]' | nawk -F'(\\[\\[)|(\\]\\])' '{for(i=2;i<=NF;i+=2) {gsub("[A-Z]|[0-9][0-9]*", " &", $i);$i="[["substr($i,2)"]]"};print}' OFS=



---------- Post updated at 08:53 AM ---------- Previous update was at 08:42 AM ----------

Quote:
Originally Posted by Franklin52
Another one with sed:

Code:
echo '[[HelloInCapitals]] or [[PharmaceuticalSocietyOfGreatBritainVBoots1952]]' | 
sed 's/[A-Z]/ &/g; s/\[ /\[/g'

Code:
echo '[[HelloInCapitals]] OrAnd [[PharmaceuticalSocietyOfGreatBritainVBoots1952]]' | sed 's/[A-Z]/ &/g; s/\[ /\[/g'
[[Hello In Capitals]]  Or And [[Pharmaceutical Society Of Great Britain V Boots1952]]

 

We Also Found This Discussion For You

1. UNIX for Dummies Questions & Answers

Directory find in small and capitals

I've a very trivial thing bothering me. I'm rather new in scripting so I'll keep asking stupid questions. Here is small script that does backup of mails. --- for i in `cat /maildir.dir` do echo $i maildir=`echo $i|sed 's@^./usr/@@'` for j in $i/* do && { st="`find $j/backup -name "*"... (3 Replies)
Discussion started by: nitin
3 Replies

Featured Tech Videos

All times are GMT -4. The time now is 01:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy