sed script to change:
- if( -> if (
- if....){ _> if...) {
- }else -> } else
- else{ -> else {
- for( -> for (
- for...){ -> for...) {
find . -type f -name "*.php" -exec sed -i -e 's/if(/if (/g' -e 's/if\(.*\)){/if\1) {/g' -e 's/for(/for (/g' -e 's/for\(.*\)){/for\1) {/g' -e 's/else{/else {/g' -e 's/}else/} else/g' {} \;
I had forgotten "foreach":
find . -type f -name "*.php" -exec sed -i -e 's/foreach(/foreach (/g' -e 's/foreach\(.*\)){/\1) {/g' {} \;
sed script to trim trailing spaces:
find . -type f -name "*.php" -exec sed -i 's/[ \t]*$//' {} \;
this may also be handy, to strip ^M characters:
(from http://www.computing.net/answers/unix/remove-m-and-line-feeds/6934.html)
anupam May 23, 2005 at 21:11:55 PacificHi..to remove ^M, give the command :
sed -e 's/^M//g' filename
you will have to write the control-M as follows : first press control-V,then control-M,this will show the correct control-M on the command line.
For removing the linefeeds,try this :
sed -e 's/.$//g' filename
this will remove the last character from the line,which happens to be the line feed.