Results 1 to 2 of 2
hi guys...
i have multiple php files with some comments. i want to remove the comment automatically using grep or find or some other built in linux command. the comment ...
- 09-06-2011 #1Just Joined!
- Join Date
- Jan 2010
- Posts
- 4
help with search and replace
hi guys...
i have multiple php files with some comments. i want to remove the comment automatically using grep or find or some other built in linux command. the comment is like this
* this is an example of a line
how can i use the command line to automatically find the above line with starts with * and remove the entire line automatically? i know what the exact line to remove is, so please help me with the command i need to type. please take note that the starting character starts with a blank space and then the aterick character followed by the line to be removed
please help me guys... im lost
- 09-06-2011 #2
Something like this should do it:
This will *not yet* change any files, but just output a concatination of all php files with the mentioned line removed.Code:find <PHP_DIRECTORY> -type f -iname "*\.php" -exec sed '/^\([[:blank:]]\)\* this is an example of the line/d' {} \;
After you verified the correct output, you can add the -i flag to sed for in-place editing.
Note:
The sed will look for exactly *one* space/tab, followed by "* this is an example of the line".
But it easy to adjust to e.g. multipe spaces or none at all or optional.
That said:
is not a comment in php, it is rather (for a comment block)Code:*
But maybe the "body" of your comments have space + asteriksCode:/* . . */
Last edited by Irithori; 09-06-2011 at 01:14 PM.
You must always face the curtain with a bow.


Reply With Quote