I need to delete all comments inside all script files in the current folder and sub folders. All comment lines start with //. I want to delete the whole line
Asked
Active
Viewed 863 times
1 Answers
4
find . -type f |xargs sed -i '\#^//#d'
the find part find all files, and the sed part removes all lines starting with //
You can add -name option in find to do further filtering. check man find to get more useful information.
Your pattern contains slash /, so with sed's default /pattern/d you have to do some escaping. I used # as delimiter to save that kind of works, and made the code easier to read.
Kent
- 189,393
- 32
- 233
- 301