0

I used PHP array

$lang['module']['1'] = 'Title';
$lang['module']['2'] = 'Title2';
$lang['value'] = 'text123';

how i can use replace in terminal Key Value to CASE UPPER ?

$lang['VALUE']
$lang['MODULE']['1']
$lang['MODULE']['2']
etc .. recursion

find /var/www/site.net/blog/ -iname '*.php' | xargs grep -E '\$lang\[' -sl

finded only $lang[ ...

Please help me.

1
  • Should 1 and 2 also be changed? Eg., can text appear there? Commented Jul 2, 2012 at 22:01

1 Answer 1

2
find /var/www/site.net/blog/ -iname '*.php' -exec grep -l "\$lang\['" {} \; \
-exec sed -i.bak "s/$lang\['\([^']*\)']/$lang['\U\1']/" {} \;

-i option is used with .bak to make backup file with .bak extension on the each file sed will change. It is useful in case there is type in sed and you will not loose all your data. In case you're sure everything is ok, you can use just -i. In this case it won't make a backup.

4
  • Let's hope he has GNU sed for the \U. Commented Jul 2, 2012 at 22:08
  • find /var/www/site.net/blog/ -iname '*.php' -exec sed -E "s/$lang\['\([^']*\)']/$lang['\U\1']/" {} \; is not work Commented Jul 3, 2012 at 4:38
  • my php array dinamic $lang['VALUE'] $lang['l1']['l2']['l3'] etc.. Commented Jul 3, 2012 at 4:39
  • What's wrong? Are there any errors? Can you show them? Commented Jul 3, 2012 at 7:07

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.